Hi, I'm using an Oracle database and trying to query the data from it and display it in a time-series chart. My code compiles and my applet loads but the horizontal axis does not hava a name and there is no data displayed. This is my code:
public class JChartApplet extends JApplet {
// Constructs the applet
public JChartApplet() {
JDBCXYDataset data = null;
// Connect to the Oracle database
try
{
Class.forName ("oracle.jdbc.driver.OracleDriver").newInstance();
String url = //connect to Oracle server - it works
Connection con = DriverManager.getConnection(url, "username", "password");
data = new JDBCXYDataset(con);
data.executeQuery("SELECT dates, oas_3pt, oas_4pt FROM table_name ORDER BY dates ASC");
con.close();
}
catch (Exception e) {
System.err.println(e.getMessage());
}
JFreeChart chart1 = ChartFactory.createTimeSeriesChart("TSM MODEL", "Date", "Value",
data, true, true, false);
ChartPanel panel1 = new ChartPanel(chart1, 400, 300, 200, 100, 400, 200,
true, false, false, false, true, true);
getContentPane().add(panel1);
}
}
I don't know what I'm doing wrong since I get no errors and I can't find any other examples. So any help would be greatly appreciated.
Thanks,
Luka
JDBCXYDataset - no data is displayed
Re: JDBCXYDataset - no data is displayed
One thing to check is that the first column of your query is returning a DATE, TIME or TIMESTAMP value. A common mistake is to return a VARCHAR that looks like a date.
It is difficult to say much else without seeing what the results of the query are.
Regards,
Dave Gilbert
It is difficult to say much else without seeing what the results of the query are.
Regards,
Dave Gilbert