我正在尝试使用JFreeChart
来绘制曲线,但是我很好地从数据库中获取了值。我用这段代码创建了一个,但是我在这行datset.executeQuery(rqt);
中遇到了一个错误,我无法理解到底出了什么问题,所以如果有人能告诉我,我将不胜感激,这里是我使用的代码
try {
String rqt = "SELECT `poste`,`S1` FROM `allin` ";
JDBCCategoryDataset datset;
datset = new JDBCCategoryDataset(connection());
if (con != null) {
System.out.println("connect");
} else {
System.out.println(" not connect");
}
datset.executeQuery(rqt);
JFreeChart chart = ChartFactory.createBarChart("Data", "X", "Y", datset, PlotOrientation.VERTICAL, false, true, true);
if (chart != null) {
System.out.println("done");
} else {
System.out.println(" not done");
}
BarRenderer rend = null;
CategoryPlot plot = null;
rend = new BarRenderer();
ChartPanel cPanel;
cPanel = new ChartPanel(chart);
cPanel.setBackground(new Color(54, 63, 73));
Chartpanel.add(cPanel, BorderLayout.CENTER);
Chartpanel.validate();
} catch (SQLException ex) {
Logger.getLogger(Courbes.class.getName()).log(Level.SEVERE, null, ex);
}
}