I can get it to compile ok but when I step through debugging it the demo crashes while doing createTimeSeriesChart.
Error:
Code: Select all
java.lang.VerifyError: org.jfree.chart.JFreeChartInfo
at org.jfree.chart.JFreeChart.<clinit>(JFreeChart.java:187)
at org.jfree.chart.ChartFactory.createTimeSeriesChart(ChartFactory.java:1456)
at JDBCXYChartDemo.<init>(JDBCXYChartDemo.java:30)
at JDBCXYChartDemo.main(JDBCXYChartDemo.java:91)
Exception in thread main
Process exited with exit code 1.
Code: Select all
import java.awt.Color;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.data.JDBCXYDataset;
import org.jfree.data.XYDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class JDBCXYChartDemo extends ApplicationFrame {
/**
* Constructs the demo application.
*
* @param title the frame title.
*/
public JDBCXYChartDemo(String title) {
super(title);
// read the data from the database...
XYDataset data = readData();
// create the chart...
// THIS IS WHERE IT's DIEING
JFreeChart chart = ChartFactory.createTimeSeriesChart(
"JDBC XY Chart Demo", // chart title
"Date",
"Value",
data, // data
true, // include legend
true,
false
);
// set the background color for the chart...
chart.setBackgroundPaint(Color.yellow);
// add the chart to a panel...
ChartPanel chartPanel = new ChartPanel(chart);
setContentPane(chartPanel);
}
private XYDataset readData() {
JDBCXYDataset data = null;
String usr = "scott";
String pwd = "tiger";
String url = "jdbc:oracle:thin:"+usr+"/"+pwd+"@myserver:1521:ORACLEBX";
Connection con;
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch (ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try{
con = DriverManager.getConnection(url);
data = new JDBCXYDataset(con);
String sql = "SELECT * FROM XYDATA1";
data.executeQuery(sql);
con.close();
}
catch (SQLException e) {
System.err.print("SQLException: ");
System.err.println(e.getMessage());
}
catch (Exception e) {
System.err.print("Exception: ");
System.err.println(e.getMessage());
}
return data;
}
/**
* Starting point for the demo...
*
* @param args ignored.
*/
public static void main(String[] args) {
JDBCXYChartDemo demo = new JDBCXYChartDemo("JDBC XY Chart Demo");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}
Code: Select all
DATE SERIES1 SERIES2 SERIES3
--------- ---------- ---------- ----------
20-JUL-04 54.3 32.1 53.4
22-JUL-04 43.4 54.3 75.2
15-MAY-05 39.6 55.9 37.1
17-OCT-04 35.4 55.2 27.5
24-JUL-04 33.9 49.8 22.3
16-OCT-04 35.2 48.4 17.7
21-AUG-04 38.9 49.7 15.3
16-JUN-05 36.3 44.4 12.1
07-NOV-04 31 46.3 11