-
Next Method for ResultSet ignoring the first result
I have made a connection to an SQL database and executed a query returning
a result set containing about 20 rows. However when I try to print the results
the first record seems to be excluded. Some of my code is as follows :
try
{
rs.next();
h++;
System.out.println(h);
}
final Object [][] data = new Object[h][5];
Any suggestions would be welcome
-
Re: Next Method for ResultSet ignoring the first result
The error must be in some other part of your code, then. What you have
posted is not enough to identify the problem.
PC2
"MAK" <majella.kavanagh@citicorp.com> wrote in message
news:3c3d6b80$1@147.208.176.211...
>
> I have made a connection to an SQL database and executed a query returning
> a result set containing about 20 rows. However when I try to print the
results
> the first record seems to be excluded. Some of my code is as follows :
> try
> {
> rs.next();
> h++;
> System.out.println(h);
>
> }
>
> final Object [][] data = new Object[h][5];
>
> Any suggestions would be welcome
>
>
-
Re: Next Method for ResultSet ignoring the first result
You forgot the loop "while", uderstood?
int h=0;
try {
while (rs.next()) {
h++;
System.out.println(h);
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks