aspose file tools*
The moose likes JDBC and the fly likes ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
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: 39828
    
  28
. . . 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://aspose.com/file-tools
 
subject: ResultSet