problem using JDBCXYChartDemo demo

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Post Reply
md315
Posts: 7
Joined: Wed Jun 23, 2004 4:43 pm
Location: us

problem using JDBCXYChartDemo demo

Post by md315 » Tue Jul 20, 2004 1:16 am

I just purchased the documentation for JFreeChart and tried using one of the demo's for doing a JDBC XY chart called JDBCXYChartDemo.java .
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.
JDBCXYChartDemo.java :

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);
    }
}
TABLE DATA:

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

md315
Posts: 7
Joined: Wed Jun 23, 2004 4:43 pm
Location: us

Post by md315 » Tue Jul 20, 2004 1:28 am

To followup, it appears that many (if not all) of the premium demo's give me the same error. But I don't get this error if I run the main jfreechart demo. Both are 9.20...

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. 

david.gilbert
JFreeChart Project Leader
Posts: 11732
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Tue Jul 20, 2004 8:57 am

My first thought is that maybe you don't have the correct version of JCommon (jcommon-0.9.5.jar is required). If it isn't that, can you tell me some more details about your operating environment (OS, JDK version) - I'm seeing a few reports of this problem, and I'd like to figure out the cause.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Ask your company to buy the JFreeChart Developer Guide

md315
Posts: 7
Joined: Wed Jun 23, 2004 4:43 pm
Location: us

Post by md315 » Tue Jul 20, 2004 1:51 pm

I think I figured it out. I am using JFreeReports (jfreereport-0.8.4_10) in the same project which has a different JCommon jar within it's lib's. When I created a project for charts on it's own it worked fine.
:D

bRADk

Post by bRADk » Wed Aug 04, 2004 4:30 pm

Yes, I am using JBuilder X and and I had to download the 0.9.5 common lib from SourceForge (I had downloaded the 0.9.4 at jfree.org which is why I think so many people have this problem, the web site needs to be updated).

And I also needed to move it to the top of the classpath... I can now have the reports and the charts in the same project and no problems.

Post Reply