diff options
author | 2013-06-20 18:30:54 +0700 | |
---|---|---|
committer | 2013-06-20 18:30:54 +0700 | |
commit | 781648961858a5180098954fc32463c32c88eaa6 (patch) | |
tree | 0945918c64ab86a24fce1b95c7242eb9bf3322b1 | |
parent | 505feda055a1f5c59aea53f26680bbbbb0553a0a (diff) |
User.getUsersByID
-rw-r--r-- | src/com/juick/server/UserQueries.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/com/juick/server/UserQueries.java b/src/com/juick/server/UserQueries.java index e44017fa..d6f6045c 100644 --- a/src/com/juick/server/UserQueries.java +++ b/src/com/juick/server/UserQueries.java @@ -90,6 +90,30 @@ public class UserQueries { return user; } + public static ArrayList<com.juick.User> getUsersByID(Connection sql, ArrayList<Integer> uids) { + ArrayList<com.juick.User> users = new ArrayList<com.juick.User>(); + + PreparedStatement stmt = null; + ResultSet rs = null; + try { + stmt = sql.prepareStatement("SELECT id,nick FROM users WHERE id IN (" + Utils.convertArray2String(uids) + ")"); + rs = stmt.executeQuery(); + rs.beforeFirst(); + while (rs.next()) { + com.juick.User u = new com.juick.User(); + u.UID = rs.getInt(1); + u.UName = rs.getString(2); + users.add(u); + } + } catch (SQLException e) { + System.err.println(e); + } finally { + Utils.finishSQL(rs, stmt); + } + + return users; + } + public static String getJIDbyUID(Connection sql, int UID) { String jid = null; |