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("");
}
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
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();
}
}