aspose file tools
The moose likes JDBC and the fly likes ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "ResultSet" Watch "ResultSet" New topic
Author

ResultSet

lape show
Greenhorn

Joined: Feb 07, 2010
Posts: 6
Please how can i get the number of rows returned by a resultset. i need to pass data retrieved from SQL into an array then to the table model and finally to the jtable, but i need to know the size of the array.


lape
Brian Enochson
Greenhorn

Joined: Apr 12, 2011
Posts: 14

This has been covered. http://www.coderanch.com/t/303346/JDBC/java/find-number-rows-resultset.

What you can also do is a select count with an identical where clause to your where used for the actual select?

Lastly, instead of using an array where you need to allocate it, add your results from your result set to an ArrayList as it will grow dynamically.

Brian

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32712
    
    4
. . . and welcome to the Ranch, both of you
lape show
Greenhorn

Joined: Feb 07, 2010
Posts: 6
Thanks a bunch!!!
Brian Enochson
Greenhorn

Joined: Apr 12, 2011
Posts: 14

Thank you.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: ResultSet
 
Similar Threads
Display Data Records in Table
Passing VARRAYS to Java
Resultsets survives failure
returning a ResultSet?
SQL Array Question