Sometimes you can do something like a count() function to get the number of records
that meet a certain criteria before you get the full resultset. For instance, if you
want the number of records where the first_name variable is "Fred"
ResultSet rs = statement.executeQuery("select count(*) from database where
first_name=\"Fred\"");
rs.next();
int count = rs.getInt(1);
rs.close();
The variable count now contains the number of records. You could then do another
query to get the recordset like
ResultSet resultset = statement.executeQuery("select * from database where
first_name=\"Fred\"");
etc etc etc
Not every system is going to support the count() function but you can give it a try.
-----Original Message-----
From: Peter Barraud [mailto:[EMAIL PROTECTED]]
Sent: Friday, October 05, 2001 4:48 AM
To: [EMAIL PROTECTED]
Subject: RE: recordcount in jdbc 1
thanx but the problem is that if I do collect the data into a list then the
resultset is lost
so if I want to access the records I will have to access the list.
Am I right or is there a way to still access the records in the resultset
peter
-----Original Message-----
From: Arnaud Hallais [mailto:[EMAIL PROTECTED]]
Sent: 05 October, 2001 12:35 PM
To: [EMAIL PROTECTED]
Subject: Re: recordcount in jdbc 1
Hi,
there is no way other than going through the all resultSet to know how many
lines are in it.
So two solutions :
// solution 1:
run your query, count the number of lines,re-run your query (to get a fresh
resultset), go through it to treat data
--> problem: if someone commits any new value between the two query run,
you'll get different row count for the two query
// solution 2:
run your query, collect data into a dynamic structure like ArrayList or what
ever you think is good for you.
--> problem: this solution can take a lot of memory, but it is always right
----- Original Message -----
From: "Peter Barraud" <[EMAIL PROTECTED]>
To: "'swing'" <[EMAIL PROTECTED]>
Sent: Friday, October 05, 2001 5:58 AM
Subject: recordcount in jdbc 1
> Hi,
> Anybody has any idea of how to get the recordcount of a resultset using
jdbc
> 1. Not JDBC 2.
> Any suggestions would be great
> _______________________________________________
> Advanced-swing mailing list
> [EMAIL PROTECTED]
> http://eos.dk/mailman/listinfo/advanced-swing
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing