From 781648961858a5180098954fc32463c32c88eaa6 Mon Sep 17 00:00:00 2001 From: Ugnich Anton Date: Thu, 20 Jun 2013 18:30:54 +0700 Subject: User.getUsersByID --- src/com/juick/server/UserQueries.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src') 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 getUsersByID(Connection sql, ArrayList uids) { + ArrayList users = new ArrayList(); + + 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; -- cgit v1.2.3