diff options
author | Vitaly Takmazov | 2015-10-24 18:09:15 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2015-10-24 18:09:15 +0300 |
commit | d00fd7705cb1a4b085eed7f34df2f1c6d9a69f76 (patch) | |
tree | 70a83e0e30a4195855484f820c0322e84405bc04 /src/main/java/com/juick/server/PushQueries.java | |
parent | b5df0e1c2664a8a1a0f9042745dd608773fedce3 (diff) |
moving to Gradle
Diffstat (limited to 'src/main/java/com/juick/server/PushQueries.java')
-rw-r--r-- | src/main/java/com/juick/server/PushQueries.java | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/main/java/com/juick/server/PushQueries.java b/src/main/java/com/juick/server/PushQueries.java new file mode 100644 index 00000000..84f42722 --- /dev/null +++ b/src/main/java/com/juick/server/PushQueries.java @@ -0,0 +1,68 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.juick.server; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; + +/** + * + * @author ugnich + */ +public class PushQueries { + + public static String getAndroidRegID(Connection sql, int uid) { + return SQLHelpers.getString(sql, "SELECT regid FROM android WHERE user_id=?", uid); + } + + public static ArrayList<String> getAndroidSubscribers(Connection sql, int uid) { + ArrayList<String> regids = new ArrayList<String>(); + + PreparedStatement stmt = null; + ResultSet rs = null; + try { + stmt = sql.prepareStatement("SELECT regid FROM android INNER JOIN subscr_users ON (subscr_users.user_id=? AND android.user_id=subscr_users.suser_id)"); + stmt.setInt(1, uid); + rs = stmt.executeQuery(); + rs.beforeFirst(); + while (rs.next()) { + regids.add(rs.getString(1)); + } + } catch (SQLException e) { + System.err.println(e); + } finally { + Utils.finishSQL(rs, stmt); + } + return regids; + } + + public static String getWinPhoneURL(Connection sql, int uid) { + return SQLHelpers.getString(sql, "SELECT url FROM winphone WHERE user_id=?", uid); + } + + public static ArrayList<String> getWinPhoneSubscribers(Connection sql, int uid) { + ArrayList<String> urls = new ArrayList<String>(); + + PreparedStatement stmt = null; + ResultSet rs = null; + try { + stmt = sql.prepareStatement("SELECT url FROM winphone INNER JOIN subscr_users ON (subscr_users.user_id=? AND winphone.user_id=subscr_users.suser_id)"); + stmt.setInt(1, uid); + rs = stmt.executeQuery(); + rs.beforeFirst(); + while (rs.next()) { + urls.add(rs.getString(1)); + } + } catch (SQLException e) { + System.err.println(e); + } finally { + Utils.finishSQL(rs, stmt); + } + return urls; + } +} |