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) );
}
...