aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server/SubscriptionsQueries.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-01-10 16:56:51 +0300
committerGravatar Vitaly Takmazov2016-01-10 16:56:51 +0300
commitc37ed56f884661666b964e47efd23a36be9b24d4 (patch)
tree64917e400d9c97fac185b4f34fd0063314bb7937 /src/main/java/com/juick/server/SubscriptionsQueries.java
parent439d42ef6d60f0a535fdfa2457da8417b70d966a (diff)
logger, diamond and arraylist refactoring
Diffstat (limited to 'src/main/java/com/juick/server/SubscriptionsQueries.java')
-rw-r--r--src/main/java/com/juick/server/SubscriptionsQueries.java39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/main/java/com/juick/server/SubscriptionsQueries.java b/src/main/java/com/juick/server/SubscriptionsQueries.java
index d0f5f308..637c2bcf 100644
--- a/src/main/java/com/juick/server/SubscriptionsQueries.java
+++ b/src/main/java/com/juick/server/SubscriptionsQueries.java
@@ -9,6 +9,9 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
*
@@ -16,8 +19,10 @@ import java.util.ArrayList;
*/
public class SubscriptionsQueries {
- public static ArrayList<String> getJIDSubscribedToUser(Connection sql, int uid, boolean friendsonly) {
- ArrayList<String> jids = new ArrayList<String>();
+ private static final Logger logger = Logger.getLogger(SubscriptionsQueries.class.getName());
+
+ public static List<String> getJIDSubscribedToUser(Connection sql, int uid, boolean friendsonly) {
+ List<String> jids = new ArrayList<>();
PreparedStatement stmt = null;
ResultSet rs = null;
@@ -36,27 +41,27 @@ public class SubscriptionsQueries {
jids.add(rs.getString(1));
}
} catch (SQLException e) {
- System.err.println(e);
+ logger.log(Level.SEVERE, "sql exception", e);
} finally {
Utils.finishSQL(rs, stmt);
}
return jids;
}
- public static ArrayList<String> getJIDSubscribedToUserAndTags(Connection sql, int uid, int mid) {
- ArrayList<String> jids = new ArrayList<String>();
+ public static List<String> getJIDSubscribedToUserAndTags(Connection sql, int uid, int mid) {
+ List<String> jids = new ArrayList<>();
PreparedStatement stmt = null;
ResultSet rs = null;
String tbl = "subscr_jids_" + mid;
- ArrayList<Integer> tags = MessagesQueries.getMessageTagsIDs(sql, mid);
+ List<Integer> tags = MessagesQueries.getMessageTagsIDs(sql, mid);
try {
stmt = sql.prepareStatement("CREATE TEMPORARY TABLE " + tbl + "(user_id INT UNSIGNED NOT NULL) ENGINE=MEMORY");
stmt.executeUpdate();
} catch (SQLException e) {
- System.err.println(e);
+ logger.log(Level.SEVERE, "sql exception", e);
} finally {
Utils.finishSQL(null, stmt);
}
@@ -69,7 +74,7 @@ public class SubscriptionsQueries {
stmt = sql.prepareStatement(query);
stmt.executeUpdate();
} catch (SQLException e) {
- System.err.println(e);
+ logger.log(Level.SEVERE, "sql exception", e);
} finally {
Utils.finishSQL(null, stmt);
}
@@ -87,7 +92,7 @@ public class SubscriptionsQueries {
jids.add(rs.getString(1));
}
} catch (SQLException e) {
- System.err.println(e);
+ logger.log(Level.SEVERE, "sql exception", e);
} finally {
Utils.finishSQL(rs, stmt);
}
@@ -96,7 +101,7 @@ public class SubscriptionsQueries {
stmt = sql.prepareStatement("DROP TABLE " + tbl);
stmt.executeUpdate();
} catch (SQLException e) {
- System.err.println(e);
+ logger.log(Level.SEVERE, "sql exception", e);
} finally {
Utils.finishSQL(null, stmt);
}
@@ -104,8 +109,8 @@ public class SubscriptionsQueries {
return jids;
}
- public static ArrayList<String> getJIDSubscribedToComments(Connection sql, int mid, int ignore_uid) {
- ArrayList<String> jids = new ArrayList<String>();
+ public static List<String> getJIDSubscribedToComments(Connection sql, int mid, int ignore_uid) {
+ List<String> jids = new ArrayList<>();
PreparedStatement stmt = null;
ResultSet rs = null;
@@ -119,17 +124,17 @@ public class SubscriptionsQueries {
jids.add(rs.getString(1));
}
} catch (SQLException e) {
- System.err.println(e);
+ logger.log(Level.SEVERE, "sql exception", e);
} finally {
Utils.finishSQL(rs, stmt);
}
return jids;
}
- public static ArrayList<String> getJIDSubscribedToUserRecommendations(Connection sql, int uid, int mid, int muid) {
- ArrayList<String> jids = new ArrayList<String>();
+ public static List<String> getJIDSubscribedToUserRecommendations(Connection sql, int uid, int mid, int muid) {
+ List<String> jids = new ArrayList<>();
- ArrayList<Integer> tags = MessagesQueries.getMessageTagsIDs(sql, mid);
+ List<Integer> tags = MessagesQueries.getMessageTagsIDs(sql, mid);
PreparedStatement stmt = null;
ResultSet rs = null;
@@ -154,7 +159,7 @@ public class SubscriptionsQueries {
jids.add(rs.getString(1));
}
} catch (SQLException e) {
- System.err.println(e);
+ logger.log(Level.SEVERE, "sql exception", e);
} finally {
Utils.finishSQL(rs, stmt);
}