Passing data between MySql and jFree results in Java Crash

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
aram535
Posts: 25
Joined: Thu Apr 24, 2008 11:59 pm

Passing data between MySql and jFree results in Java Crash

Post by aram535 » Mon Jun 29, 2009 4:52 pm

I have a very odd problem. I'm doing 18 MySql "select count(*) from .... " based on 2 Enums (3 x 6). Fairly simple stuff.

The main problem is this:

1) If I leave the MySQL stuff and comment out the createChart(dataset) it works.
2) If I leave the createChart(dataset) and replace the MySQL statements with Random.getInt() it works.

If I leave both in, it works ONCE, and crashes Java every time after that until I recompile the .class file .. than it works once again.

System:

Vista x64 w/SP1
Intel Core2 Quad Q6600
4 GB RAM
Eclipse 3.4.2
JFreeChart 1.0.13 (also tried with 1.0.12)
JCommon 1.0.16
MySQL Connector 5.1.7
Tried with both JDK 1.5.0_16 and 1.6.0_13

Now on my CentOS Machine running JDK 1.6.0_03 I'm not getting the java crash, so not sure if it's Vista, 64-bit, 1.6.0_13 or what that is causing the crash. Any help would be appreciated.

Here is the detail in case anyone wants to take a look:

Code: Select all

Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(dbConString, dbUserName, dbPassWord);
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
	for (EquipmentTypes equipment : EquipmentTypes.values()) {
		for (EoX eox : EoX.values()) {
			Statement stmt = con.createStatement();
					String sqlStmt = "select count(*) from `" .... 
					ResultSet rs = stmt.executeQuery(sqlStmt);
					if (rs.next()) {
						eoxCount = rs.getInt(1);
					} else {
						logger.fatal("Error, no data at all was returned.");
						System.exit(-1);
					}
					dataset.addValue((eoxCount+0), equipment.getName(), eox.getName());
					rs.close();
					stmt.close();
		} 
	}
	con.close(); 

        createChart(dataset);


Here is a quick for loop of the data:

Code: Select all

			for (int row = 0; row < dataset.getRowCount(); row++) {
				System.out.print(dataset.getRowKey(row) + " ");
				for (int col = 0; col < dataset.getColumnCount(); col++) {
					System.out.print(dataset.getValue(row, col)+ " ");
				}
				System.out.println("");
			}
Output:

Code: Select all

Chassis 65.0 65.0 64.0 18.0 8.0 0.0 
Module 341.0 337.0 336.0 13.0 13.0 0.0 
Software 0.0 29.0 29.0 0.0 17.0 14.0 
Now it works ONCE, the second time and every time after that until I recompile the class file it crashes with:

Code: Select all

Faulting application javaw.exe, version 6.0.130.3, time stamp 0x49b565e0, faulting module nvd3dumx.dll, version 7.15.11.7556, time stamp 0x4807b9f9, exception code 0xc0000409, fault offset 0x0000000000334a1f, process id 0x878, application start time 0x01c9f8cc5659403f.


And the Jfree

Code: Select all

private static void createChart(DefaultCategoryDataset dataset) {
		// JFreeChart chart = ChartFactory.createBarChart(
		JFreeChart chart = ChartFactory.createBarChart3D(EEMT, // title
				"", // domain axis label
				"", // range axis label
				dataset, // data
				PlotOrientation.VERTICAL, // orientation
				true, // include legend
				false, // tooltips?
				false // URLs?
		);

               // All other settings are commented out

		try {
			OutputStream out = new BufferedOutputStream(new FileOutputStream(new File(EEMTFN)));
			ChartUtilities.writeScaledChartAsPNG(out, chart, 550, 400, 6, 6);
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
}

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Re: Passing data between MySql and jFree results in Java Crash

Post by skunk » Mon Jun 29, 2009 8:26 pm

Does it work any better if you pass this flag on the command line?

Code: Select all

-Dsun.java2d.d3d=false

aram535
Posts: 25
Joined: Thu Apr 24, 2008 11:59 pm

Re: Passing data between MySql and jFree results in Java Crash

Post by aram535 » Mon Jun 29, 2009 8:47 pm

It still crashes java inside Eclipse, but it has to be something inside Eclipse.

I exported everything as a jar file and it runs fine from command line with the same JRE, so the problem is an incompatibility within Eclipse and JRE 1.6. I'm going to try to un-install all of 1.6 to see if that helps.

Locked