aboutsummaryrefslogtreecommitdiff
path: root/src/com/juick/server/UserQueries.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/juick/server/UserQueries.java')
-rw-r--r--src/com/juick/server/UserQueries.java53
1 files changed, 50 insertions, 3 deletions
diff --git a/src/com/juick/server/UserQueries.java b/src/com/juick/server/UserQueries.java
index f0c5a57f..f1b235af 100644
--- a/src/com/juick/server/UserQueries.java
+++ b/src/com/juick/server/UserQueries.java
@@ -68,7 +68,7 @@ public class UserQueries {
return uid;
}
- public static com.juick.User getUserByNick(Connection sql, String username) {
+ public static com.juick.User getUserByName(Connection sql, String username) {
com.juick.User user = null;
PreparedStatement stmt = null;
@@ -90,13 +90,36 @@ public class UserQueries {
return user;
}
+ public static ArrayList<com.juick.User> getUsersByName(Connection sql, ArrayList<String> unames) {
+ 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 nick IN (" + Utils.convertArrayString2String(unames) + ")");
+ rs = stmt.executeQuery();
+ rs.beforeFirst();
+ while (rs.next()) {
+ com.juick.User user = new com.juick.User();
+ user.UID = rs.getInt(1);
+ user.UName = rs.getString(2);
+ users.add(user);
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+ return users;
+ }
+
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) + ")");
+ stmt = sql.prepareStatement("SELECT id,nick FROM users WHERE id IN (" + Utils.convertArrayInt2String(uids) + ")");
rs = stmt.executeQuery();
rs.beforeFirst();
while (rs.next()) {
@@ -114,6 +137,30 @@ public class UserQueries {
return users;
}
+ public static ArrayList<com.juick.User> getUsersByJID(Connection sql, ArrayList<String> jids) {
+ ArrayList<com.juick.User> users = new ArrayList<com.juick.User>();
+
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = sql.prepareStatement("SELECT users.id,users.nick,jids.jid FROM users INNER JOIN jids ON jids.user_id=users.id WHERE jids.jid IN (" + Utils.convertArrayString2String(jids) + ")");
+ rs = stmt.executeQuery();
+ rs.beforeFirst();
+ while (rs.next()) {
+ com.juick.User user = new com.juick.User();
+ user.UID = rs.getInt(1);
+ user.UName = rs.getString(2);
+ user.JID = rs.getString(3);
+ users.add(user);
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+ return users;
+ }
+
public static String getJIDbyUID(Connection sql, int uid) {
return SQLHelpers.getString(sql, "SELECT jid FROM jids WHERE user_id=? AND active=1", uid);
}
@@ -307,7 +354,7 @@ public class UserQueries {
PreparedStatement stmt = null;
ResultSet rs = null;
try {
- stmt = sql.prepareStatement("SELECT user_id FROM bl_users WHERE bl_user_id=? and user_id IN (" + Utils.convertArray2String(uids) + ")");
+ stmt = sql.prepareStatement("SELECT user_id FROM bl_users WHERE bl_user_id=? and user_id IN (" + Utils.convertArrayInt2String(uids) + ")");
stmt.setInt(1, visitor);
rs = stmt.executeQuery();
rs.beforeFirst();