Problem Jfreechart SQL

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
marouene_
Posts: 15
Joined: Fri Apr 01, 2011 3:32 pm
antibot: No, of course not.

Problem Jfreechart SQL

Post by marouene_ » Wed Apr 13, 2011 3:58 pm

Hello,
i have a database like this

Code: Select all

| TABLE    | CREATE TABLE                                                                                                                                         |
+----------+------------------------------------------------------------------------------------------------------------------------------------------------------+
| ftptable | CREATE TABLE `ftptable` (
  `date` date DEFAULT NULL,
  `heure` time DEFAULT NULL,
  `ftp` float DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 | 
i have also a java class that draw a Jfreechart

Code: Select all

public TimeSeries dessiner(String Hour,String debit, String table,String where)
{
	connexionBD cone = new connexionBD();
ResultSet rs = cone.execute("select "+Hour+","+debit+" from "+table+" "+where+"");
final TimeSeries series = new TimeSeries("", Minute.class);
try {
while(rs.next()){
	
	java.sql.Timestamp v1;
	
		v1 = rs.getTimestamp(""+Hour+"");
	
 	double v2=rs.getFloat(""+debit+"");

 	series.addOrUpdate( new Minute(v1), v2);
 	
 }
 rs.close();
} catch (SQLException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}
return series;
	}
when i try

Code: Select all

select date,debit from ftptable group bye date;
i can draw a chart with debit=f(days)
but when i want to draw the variation in month or year i took this problem

Code: Select all

java.lang.IllegalArgumentException: Null 'time' argument.
	at org.jfree.data.time.Minute.<init>(Minute.java:164)
	at org.jfree.data.time.Minute.<init>(Minute.java:137)
	at metier.connexionBD.dessiner(connexionBD.java:51)
and also

Code: Select all

ava.lang.IllegalArgumentException: The 'year' argument must be in range 1900 to 9999.
	org.jfree.date.SpreadsheetDate.<init>(SpreadsheetDate.java:114)
	org.jfree.date.SerialDate.createInstance(SerialDate.java:795)
	org.jfree.data.time.Day.<init>(Day.java:193)
This is my requete

Code: Select all

select month(date),debit from ftptable group by month(date); 
month(date) return values (1,2,3,4,5,...,12)

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: Problem Jfreechart SQL

Post by paradoxoff » Mon Apr 18, 2011 9:58 pm

What if you print out the values from the db to make sure that they are reasonable?

marouene_
Posts: 15
Joined: Fri Apr 01, 2011 3:32 pm
antibot: No, of course not.

Re: Problem Jfreechart SQL

Post by marouene_ » Tue Apr 19, 2011 2:46 pm

the problem is in this part of code :

Code: Select all

java.sql.Timestamp v1;
   
      v1 = rs.getTimestamp(""+Hour+"");
because when i did

Code: Select all

select date ,debit from table;
it works succesfully because the type of "date" is date.

but when i did select

Code: Select all

month(date)
it did'nt work, because the type of month(date) is int....

Locked