import java.sql.*;
public class Results
{
public static void main(String[] args)
{
int count=0;
int count1=0;
int count11=0;
String sname1=null;
String sname2=null;
try
{
Dbcon db = new Dbcon();
Connection con = db.getConnection();
Statement stmt = con.createStatement();
ResultSet rs=stmt.executeQuery("select * from Trust");
while(rs.next()==true)
{
String ar=rs.getString("status");
if(ar.equals("packet dropped"))
{
sname1="Packet Dropped";
count++;
}
if(ar.equals("packet modified"))
{
sname2="Packet Modified";
count1++;
}
}
DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
dataSet.setValue(count, sname1, "Packet Dropped");
dataSet.setValue(count1, sname2, "Packet Modifyied");
dataSet.setValue(count11, sname2, " ");
dataSet.setValue(count11, sname2, " ");
dataSet.setValue(count11, sname2, " ");
JFreeChart chart = ChartFactory.createBarChart3D("efficient", "wireless multimedi", "wsn",
dataSet, PlotOrientation.VERTICAL, true, true, true);
ChartFrame chartFrame=new ChartFrame();
chartFrame.setVisible(true);
chartFrame.setSize(800,500);
}
catch(Exception ex)
{
System.out.println(ex);
}
}
}
The errors i get are as follows *Exception in thread "main" java.lang.Error: Unresolved compilation problems: The method setValue(int, String, String) is undefined for the type DefaultCategoryDataset The method setValue(int, String, String) is undefined for the type DefaultCategoryDataset The method setValue(int, String, String) is undefined for the type DefaultCategoryDataset The method setValue(int, String, String) is undefined for the type DefaultCategoryDataset The method setValue(int, String, String) is undefined for the type DefaultCategoryDataset VERTICAL cannot be resolved or is not a field The method setVisible(boolean) is undefined for the type ChartFrame The method setSize(int, int) is undefined for the type ChartFrame如何解決這個Java代碼中的錯誤
at Results.main(Results.java:60)*
http://www.jfree.org/jfreechart/api/javadoc/org/jfree/data/category/DefaultCategoryDataset.html setValue方法期望java.lang.Comparable不是String – RamPrakash
@RamPrakash你的意思是它的原因是所有的這些錯誤 –
修復Exception的格式會大大提高您發佈的可讀性。 – anothernode