• Post Reply Bookmark Topic Watch Topic
  • New Topic

Resultset array problem  RSS feed

 
ellie patterson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
Can anyone help me with the following problem I am trying to display data as follows
disc0 disc1 disc2 disc3
type1 23 24 25 11
type2 11 7 31 10
etc where the disc is dynamic.
I have the following code (see below) and have more or less what I want but with one problem the actual values are incorrect, the first 3 values for disc0 are correct, but for the 4th type this is the sum of type2 and 3. Then for the rest of the disc columns the same values appear as for disk0. Can anyone see where I am going wrong....its driving me crazy! Any help will be gratefully received.
ResultSet disks;
disks = GetResultSet("SELECT Distinct Disks from Metrics where Branch='" + request.getParameter("Branch") + "' order by Disks");
disks.last();
String[] discs = new String[disks.getRow()-1];
disks.beforeFirst();
int j=0;
while (disks.next()) {
discs[j]=disks.getString("Disks");
//j++;
out.println("<td><b><font face=Arial, Helvetica, sans-serif size=2>" + disks.getString("Disks") + "</b></td>");
}
out.println("</tr>");
rs = GetResultSet("SELECT Disks,Type,MB from Metrics where Branch='" + request.getParameter("Branch") + "' order by Disks,Type");
int[] total = new int[j];
//for (j=0; j<=discs.length; j++) total[j] = 0;
rs.next();
sType=rs.getString("Type");
while (!sType.equals("")) {
out.println("<tr><td bgcolor=DDDDDD><font face=Arial, Helvetica, sans-serif size=2><b>" + sType + "  </b></td>");
for(j=0; j<=discs.length; j++) {
for(tot=0,rs.beforeFirst(); rs.next(); ) {
if (rs.getString("Type").compareTo(sType) > 0) break;
if (rs.getString("Type").equals(sType)) tot += rs.getInt("MB");
}
out.println("<td><font face=Arial, Helvetica, sans-serif size=2>" + tot + "</td>");
//total[j] += tot;
}
out.println("</tr>");
sType = GetNextSection(rs,sType);
}
rs.close();
out.println("<tr><td bgcolor=DDDDDD><font face=Arial, Helvetica, sans-serif size=2><b>Total</b></td>");
for (j=0; j<=discs.length; j++) {
//out.println("<td><font face=Arial, Helvetica, sans-serif size=2>" + total[j] + "</td>");
}
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the ranch ellie.
If you use the UBB code tags around your code examples to preserve the formatting of the code, more people will be willing to look through it and try to help you out.
Be aware that you can go back and edit your post to make sure that the example code is completely beautiful.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!