Generating annual report and list the data into JTable
Hi, I am stuck with my project. I know that my logic is wrong, but I couldn't figure out the solution. Please help me.
I hava a database, one of the table is the booking information.
I need to generate a report which shows the number of booking for each companies for each month.
I have three data in my database, two different companies(XX and YY), with three different months(Jan, Feb, Jul).
The problem that I encountered is that the data shown is inaccurate. It showed 6 rows of data, and the number of booking is incorrect.
It showed :
Company Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
XX100000000000
XX110000000000
YY110000100000
How can I loop for different companies and add the number of booking each time and get the right output as follows?
Company Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
XX110000000000
YY000000100000
This is my partial code:
ArrayList stringList = dao.retrieveAllBooking();
for (int i = 0; i < stringList.size(); i++) {
ab = (AllBooking) stringList.get(i);
d = ab.getDATE_OF_USE_TO();
StringTokenizer ss = new StringTokenizer((String) d, "/");
String day = ss.nextToken();
String month = ss.nextToken();
String year = ss.nextToken();
Org = o.getORG_ID();
if(month.equals("JAN")){
JanDR++;
}
if(month.equals("FEB")){
FebDR++;
}
if(month.equals("MAR")){
MarDR++;
}
if(month.equals("APR")){
//Apr = ab.getNO_OF_REQ();
AprDR++;
}
if(month.equals("MAY")){
//MayDR = ab.getNO_OF_REQ();
MayDR++;
}
if(month.equals("JUN")){
//Jun = ab.getNO_OF_REQ();
JunDR++;
}
if(month.equals("JUL")){
JulDR++;
}
if(month.equals("AUG")){
AugDR++;
}
if(month.equals("SEP")){
SepDR++;
}
if(month.equals("OCT")){
OctDR++;
}
if(month.equals("NOV")){
NovDR++;
}
if(month.equals("DEC")){
DecDR++;
}
Object[] data={Org,JanDR, FebDR, MarDR, AprDR, MayDR, JunDR, JulDR, AugDR, SepDR, OctDR, NovDR, DecDR, JanSR, FebSR, MarSR, AprSR, MaySR, JunSR, JulSR, AugSR, SepSR, OctSR, NovSR, DecSR};
tableModel.addRow(data); //add the data to the table.
I'll appreciate for your help. Thanks.

