【发布时间】:2020-07-12 06:06:13
【问题描述】:
有人可以帮我解决这个问题吗?我正在尝试使用休眠数据库创建图表,但在 for 循环“实际参数列表和形式参数列表长度不同”中出现错误。我尝试在线查找此错误,但没有得到任何解决方案。我决定从这里寻求帮助。任何帮助将不胜感激
这是我的实体类的代码:
class Student1
{
private int rno,marks1,marks2,marks3;
private String name;
public Student1() { }
public Student1(int rno,String name,int marks1,int marks2,int marks3)
{
this.rno = rno;
this.name = name;
this.marks1 = marks1;
this.marks2 = marks2;
this.marks3 = marks3;
//getter and setters
}
方法图代码如下:
public static void chartsStudent()
{
DefaultCategoryDataset d1 = new DefaultCategoryDataset();
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml");
SessionFactory sfact = cfg.buildSessionFactory();
Session session = null;
try
{
session = sfact.openSession();
System.out.println("connected");
session.beginTransaction();
List<Student1> student1list = new ArrayList<>();
student1list = session.createQuery("from Student1").list();
for(Student1 b : student1list)
{
d1.setValue(b.getName(),b.getMarks1(),b.getMarks2(),b.getMarks3());
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
finally
{
if (session !=null)
{
session.close();
System.out.println("disconnected");
}
}
JFreeChart chart = ChartFactory.createBarChart("Student Preformance",
"Subjects","Marks",d1,PlotOrientation.VERTICAL,true,true,false);
int width = 400;
int height = 400;
}
错误
【问题讨论】:
-
根据DefaultCategoryDataset.setvalue()的api,这个函数没有String, int, int, int作为参数。
-
那我应该使用什么函数而不是设置值,实际上我在这方面是全新的。@Ynjxsjmh
标签: java hibernate jfreechart