franco_c
asked on
jsp array help
I am using the following array but would like to sort it by description then location.
any suggestions?
any suggestions?
public class GetSummerPlayers09 {
ArrayList al = null;
public ArrayList getSummerPlayers09() {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://xxxxxxxxxxxx/xxxx?user=xxxx&password=xxxxxxxxxxxxxxx");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select playerID, firstName, lastName, city, state, zip, yearSchool, team, position, x_description, location from players2009");
int count=0;
al = new ArrayList();
while(rs.next()) {
int playerID = rs.getInt("playerID");
String firstName = rs.getString("firstName");
String lastName = rs.getString("lastName");
String city = rs.getString("city");
String state = rs.getString("state");
String zip = rs.getString("zip");
String yearSchool = rs.getString("yearSchool");
String team = rs.getString("team");
String position = rs.getString("position");
String x_description = rs.getString("x_description");
String location = rs.getString("location");
al.add(new Integer(playerID));
al.add(firstName);
al.add(lastName);
al.add(city);
al.add(state);
al.add(zip);
al.add(yearSchool);
al.add(team);
al.add(position);
al.add(description);
al.add(location);
count++;
}
rs.close();
st.close();
} catch (ClassNotFoundException cnfe) {
System.err.println("ClassNotFoundException Was Thrown");
cnfe.printStackTrace();
} catch (SQLException sqle) {
System.err.println("SQLException Was Thrown");
sqle.printStackTrace();
} catch (Exception e) {
System.err.println("Exception Was Thrown");
e.printStackTrace();
}
return al;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please post such questions under Java. This question has nothing to do with JSP.
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Comparator.html