Today I just start to learn JFreeChart only and this is my code`
try{
String query = "Select Purchase_Date,Total_Quantity_Purchased "
+ "from Purchases";
JDBCCategoryDataset dataset = new JDBCCategoryDataset(javaconnect.ConnecrDb(),query);
JFreeChart chart = ChartFactory.createLineChart("Chart", "Purchase Date", "Total Purchase", dataset, PlotOrientation.VERTICAL, false, true, true);
BarRenderer renderer = null;
CategoryPlot plot = null;
renderer = new BarRenderer();
ChartFrame frame = new ChartFrame("Title",chart);
frame.setVisible(true);
frame.setSize(500,650);
}catch(Exception ex){
JOptionPane.showMessageDialog(null,ex.getMessage(),"Error",JOptionPane.ERROR_MESSAGE);
}
and my result is listing out all of my database's data.
And now I want to improve it , I want to search total purchase on specific date Example from july 1 to july 10 . Is there anyway to do this?? I am new to this. Please help. TQ
Edit :
java.util.Date utilStartDate = from.getDate();
java.sql.Date sqlStartDate = new java.sql.Date(utilStartDate.getTime());
java.util.Date utilStartDate2 = to.getDate();
java.sql.Date sqlStartDate2 = new java.sql.Date(utilStartDate2.getTime());
String query = "Select Purchase_Date, Total_Purchase_Quantity from Purchasing Where Purchase_Date between "+sqlStartDate+" and "+sqlStartDate2+"";
JDBCXYDataset dataset = new JDBCXYDataset (javaconnect.ConnecrDb(),query);
JFreeChart chart = ChartFactory.createTimeSeriesChart("Query chart", "Date", "Total Order", dataset, true,true,false);
BarRenderer renderer = null;
CategoryPlot plot = null;
renderer = new BarRenderer();
ChartFrame frame = new ChartFrame("Query Chart",chart);
frame.setVisible(true);
frame.setSize(500,650);
Error give me not enough valid columns where generate by query