Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Returning a ArrayList from a jdbc resultset

807601Apr 25 2008 — edited Apr 25 2008
Hi

Im attempting to return a ArrayList from a jdbc resultset. This is the code I have so far.
public ArrayList doRead()
    {
        ArrayList results = new ArrayList();
        String query = "select * from test";
        try{
        Statement stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery(query);
        while (rs.next() ) {

	}

         
        } catch (SQLException e)
        {
         //something went wrong with the sql   
        } 
        finally 
        {
            return results;
        }
       
    }
Im having troulbe figuring out how do I insert each row of the result set into the array. So that the array can later be used by a jsp to output the results? I'd be grateful for any pointers in the right direction.

Thanks

Eamo
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 23 2008
Added on Apr 25 2008
3 comments
18,895 views