Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

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!

ArrayList output from database

511785Jul 23 2007 — edited Jul 24 2007
I have an output that I get from my Oracle database where it takes parameters from form entries and queries the database. It list the records where it works with an ArrayList to get the output. Everything works great but was wondering if there is a more efficient way to do this?
ArrayList firstnameArray = new ArrayList();
ArrayList lastnameArray = new ArrayList();
ArrayList cityArray = new ArrayList();

String myLastname = request.getParameter("firstname");
String myFirstname = request.getParameter("lastname");
String myCity= request.getParameter("city");

//DB connection here
try {
...
     while(results.next())
     {
        String theFirstname = results.getString("myFirstname");
        String theLastname = results.getString("myLastname");
        String theCity = results.getString("myCity");
        firstnameArray.add(theFirstname);
        lastnameArray.add(theLastname);
        cityArray.add(theCity);
    }
....
}
....
//output records using a for loop

    for(int i = 0;i < myParameterHere;i++)
    {
        out.write("Record value " + firstnameArray.get(i) + "  " + lastnameArray.get(i)  + "  " + cityArray.get(i) );
     }
...
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 21 2007
Added on Jul 23 2007
3 comments
304 views