aboutsummaryrefslogtreecommitdiff
path: root/src/com/juick/server/SQLHelpers.java
diff options
context:
space:
mode:
authorGravatar Ugnich Anton2013-06-20 18:22:12 +0700
committerGravatar Ugnich Anton2013-06-20 18:22:12 +0700
commita1ecda62eef3b802dbfa044f75ec0050de6ba75e (patch)
treed8d0ec6cc221cd6f0f4b034c85f47f5ef8eac5dd /src/com/juick/server/SQLHelpers.java
parentde81a033905d1c4cd18ac9b5af8a7f8fb853b121 (diff)
SQLHelpers.getArrayInteger
Users.getUserRead Users.getUserReaders
Diffstat (limited to 'src/com/juick/server/SQLHelpers.java')
-rw-r--r--src/com/juick/server/SQLHelpers.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/com/juick/server/SQLHelpers.java b/src/com/juick/server/SQLHelpers.java
new file mode 100644
index 00000000..dd83a915
--- /dev/null
+++ b/src/com/juick/server/SQLHelpers.java
@@ -0,0 +1,40 @@
+/*
+ * 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 SQLHelpers {
+
+ public static ArrayList<Integer> getArrayInteger(Connection sql, String query, int param) {
+ ArrayList<Integer> ret = new ArrayList<Integer>();
+
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = sql.prepareStatement(query);
+ stmt.setInt(1, param);
+ rs = stmt.executeQuery();
+ rs.beforeFirst();
+ while (rs.next()) {
+ ret.add(rs.getInt(1));
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+
+ return ret;
+ }
+}