aboutsummaryrefslogtreecommitdiff
path: root/src/com/juick/server/SQLHelpers.java
diff options
context:
space:
mode:
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;
+ }
+}