diff options
author | Ugnich Anton | 2013-04-14 06:44:35 +0700 |
---|---|---|
committer | Ugnich Anton | 2013-04-14 06:44:35 +0700 |
commit | de81a033905d1c4cd18ac9b5af8a7f8fb853b121 (patch) | |
tree | 9dba82f2c16d45f6148778c9d95e2829d276a873 /src/com/juick/server/PushQueries.java | |
parent | 917e44c66ee99f31b0ac655c56b598d71014652e (diff) |
PushQueries
Diffstat (limited to 'src/com/juick/server/PushQueries.java')
-rw-r--r-- | src/com/juick/server/PushQueries.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/com/juick/server/PushQueries.java b/src/com/juick/server/PushQueries.java new file mode 100644 index 00000000..a532622a --- /dev/null +++ b/src/com/juick/server/PushQueries.java @@ -0,0 +1,61 @@ +/* + * 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 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 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; + } + +} |