[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 520
  • Last Modified:

jsp array help

I am using the following array but would like to sort it by description then location.
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;
}
}

Open in new window

0
franco_c
Asked:
franco_c
  • 2
1 Solution
 
ManishLeadCommented:
0
 
sunithnairCommented:
Get it sorted from the SQL query that is the best way to do it
select playerID, firstName, lastName, city, state, zip, yearSchool, team, position, x_description, location  from players2009 order by x_description, location

Open in new window

0
 
mahomeCommented:
Please post such questions under Java. This question has nothing to do with JSP.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now