File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and the fly likes resultset into 2d array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "resultset into 2d array" Watch "resultset into 2d array" New topic

resultset into 2d array

Pratheek Patel

Joined: Feb 18, 2008
Posts: 14
Im looking for the fastest, most efficient way to parse a resultSet into a 2D array. Due to the structure of my program a 2D array is the preferable data structure, i dont want to use a map or a list.

Could anyone please point me to a simple way to parse a resultSet into a 2D array ?

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 37945
There is no such thing as a 2D array, only an array of arrays.

Your result set consists of n results, but you would have to count them first probably with the next() method. Then you would have to go back, and your results in each row would be different type, so unsuitable for an array of arrays. You could more easily create an array of FooResult objects. I am surprised you think a Foo[][] is a suitable data structure for a ResultSet.
I agree. Here's the link:
subject: resultset into 2d array
Similar Threads
JDBC Connections Freezing with Multiple Users Accessing DB
tag to loop a List
Finding number of a rows in a resultset...
Can I clone ResultSet?
Meaningful 2D array sort?