File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes ResultSet & next() issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "ResultSet & next() issue" Watch "ResultSet & next() issue" New topic

ResultSet & next() issue

Jason Stockmann

Joined: Jun 25, 2002
Posts: 6
Ok, I have an issue where I can't use scrollable options for a ResultSet, because I am using a Teradata driver that cannot handle that.
I am trying to scroll through and, for example, making it so every 8 lines (where 1 item in each row is the same number) is ultimately compressed into 1 line (thus, all the data for that identical number is in 1 line, not 8). Then, when I have this done, I complete the loop with a call that will take me to a new table row where I start the whole process over again with the next identical number set.
The problem is, with that last to complete the loop, I end up skipping the first row of each set.
I know this sounds confusing, but hopefully the code below helps some - I had to alter a lot, so I don't know ifI butchered too much.
If someone has some comments, I would be ever so grateful!
Thanks Jason
<tr align="center" class="rptRow1">
<% if (reportView.equals("blah")){
currId = Integer.parseInt(rs.getString("THING"));
saveId = currId;
}while ( && saveId == (currId = Integer.parseInt(rs.getString("THING"))));
<%}while (;%>
Michael Zalewski
Ranch Hand

Joined: Apr 23, 2002
Posts: 168
Doing this kind of logic in JSP scriptlets gets ugly. It would probably be easier if you seperated the row data into its own class.
One technique would be to wrap the ResultSet into a class, and implement read-ahead like this;

Now your Jsp can use this class like this:

The above code has only one place where is called. So you won't get the problem of calling once when you test for the end of the group, and again when you test for the end of the report.
[ January 31, 2003: Message edited by: Michael Zalewski ]
I agree. Here's the link:
subject: ResultSet & next() issue
It's not a secret anymore!