Ostrya Ostrya - 4 months ago 8
Java Question

General.ServerExceptions from TimeSeries.add

I am working on a closed system and cannot copy/paste in my code, so please forgive any typos and assume that the code work until the call to tSeries.add(tsdi); where I get the General Exception "You are trying to add data where the time period class is org.jfree.data.time.Day but the time series is expecting an instance of java.sql.date".

The end goal is creating data driven time series charts spanning Jan-Dec with each series being data from a different year. The code not shown was all taken from the demos and examples found elsewhere and works with the demo data. I am trying to insert my own data at this point and encountering problems. I am working with 1.0.19 and know that these methods have been depreciated, but I'm working with what I can find for the moment.

I have tried

tSeries.add(new Day(rsGetData.getDate("date")),rsGetData.getFloat("elevation")));


But get the same result. All of it leads me to believe that

tSeries.add(rsGetData.getDate("date"),rsGetData.getFloat("elevation"));


will work but I get the following complaint, "The Method add(TimeSeriesDataItem, Boolean) in type TimeSeries is not applicable for the arguments (Date, float)"

I have the following code (rsGetData is a valid RecordSet of Date, Float pairs):

TimeSeries tSeries = new TimeSeries(theYear, Date.class);
while(rsGetData.next()){
System.out.println("1"+rsGetData.getDate("date"));
TimeSeriesDataItem tsdi = new TimeSeriesDataItem (new Day(rsGetData.getDate("date")),rsGetData.getFloat("elevation"))
System.out.println("2"+tsdi.getValue()+"::"+tsdi.getPeriod());
tSeries.add(tsdi);
System.out.println("3");
}


Please let me know if you need any more information. Any help is greatly appreciated!

Answer

Answered my own question with a fresh set of eyes. The Date.class,

TimeSeries tSeries = new TimeSeries(theYear, Date.class);

had to be changed to Day.class,

TimeSeries tSeries = new TimeSeries(theYear, Day.class);

The given error didn't really point to that being the problem but it makes sense since the data presented to the TimeSeries tSeries is a Day not a Date.

On to the next hurdle of setting up a domain range of Jan-Dec without concern for the year.

Thanks to any all who many of looked at this question and spent time trying to figure it out. @trashgod, I will try to make my questions more complete in the future.