| Author |
JDBC Query Help!!!!!
|
Koh Khai Huat
Ranch Hand
Joined: Aug 05, 2005
Posts: 100
|
|
Hi guys i need help in query the database using JDBC. Wen i query the database the result return to me is not in order how do u get the database to return u the data in ascending order this is the code i use to query the database : try{rs = ConnectionDB.st.executeQuery("Select * from LockerInfo"); while (rs.next()) { result[l] = rs.getString("Used"); lockerID[l] = rs.getString("LockerID"); System.out.println("Result = " + result[l] + " LockerID = " + lockerID[l]); l ++; } } regards
|
if (!WorkHard){
System.out.println("Fail!!!");
}
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26144
|
|
Koh, Welcome to JavaRanch! SQL has a clause called order by, which allows you to specify what to sort the result by. So you could do "Select * from LockerInfo order by lockerid" to sort ascendingly or "Select * from LockerInfo order by lockerid desc" to sort descendingly. Note that we have a forum at the top of the page for JDBC/SQL questions. Feel free to ask database questions there in the future.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Koh Khai Huat
Ranch Hand
Joined: Aug 05, 2005
Posts: 100
|
|
thank you i will take note of that regards
|
 |
 |
|
|
subject: JDBC Query Help!!!!!
|
|
|