Java Arrays...
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Dan_Hansen
Posted On:   Saturday, September 8, 2001 07:34 PM

Folks -- I've been off in management-land for a few years and am currently trying to refresh my programming skills in Java... One thing I'm beating my head against is loading 44 records from a mySQL DB into an array via a method to be callable by JSP pages. The method needs to take a string paramenter as an argument, queries the DB, and returns an array of 44 "rows" by 4 "columns" (two Integers and two Strings).

I'm making my head hurt trying to figure out how to create the method definition and return type to accomplish this. Any help much appreciated!!

Dan Hansen

Re: Java Arrays...

Posted By:   Cory_Powers  
Posted On:   Monday, September 10, 2001 05:18 AM

You may also want to check out the RowSet object from Sun. It can be used just like a ResultSet except it does not require a database connection. It is in early access but, I have been using it for a couple of months without issue. You can download it from Sun's early access site.

Re: Java Arrays...

Posted By:   AlessandroA_Garbagnati  
Posted On:   Sunday, September 9, 2001 08:24 AM

Dan,


I think that there are many solutions to your problem. You could create a very simple bean that correspond to the row of the database (with two strings and two Integer) and then creating an array of that bean and passing it back to the caller.


Another solution could be returing a bi-dimensional array of Object (Object[][] retVal = new Object[44][4]) and insert the values in that array directly during the ResultSet loop.


Between the two I would prefer the first, but the second would be faster to write.

About | Sitemap | Contact