diff options
author | Ugnich Anton | 2014-04-13 13:02:55 +0700 |
---|---|---|
committer | Ugnich Anton | 2014-04-13 13:02:55 +0700 |
commit | d5c3d6b5cc0decd1b22cb165f73656aade85e20f (patch) | |
tree | c42d991f250bf81298d374e9d849cf4aca7f2f78 /src | |
parent | e6aecf508d4c3b115bd6811678604b8a351518d4 (diff) |
Utils: buildQueryArray, stmtSetStringArray
Diffstat (limited to 'src')
-rw-r--r-- | src/com/juick/server/Utils.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/com/juick/server/Utils.java b/src/com/juick/server/Utils.java index d37931d0..f97797d7 100644 --- a/src/com/juick/server/Utils.java +++ b/src/com/juick/server/Utils.java @@ -17,6 +17,7 @@ */ package com.juick.server; +import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; @@ -50,6 +51,24 @@ public class Utils { return q; } + public static String buildQueryArray(String query1, int length, String query2) { + String ret = query1; + for (int i = 0; i < length; i++) { + if (i > 0) { + ret += ","; + } + ret += "?"; + } + ret += query2; + return ret; + } + + public static void stmtSetStringArray(PreparedStatement stmt, int offset, String strs[]) throws SQLException { + for (int i = 0; i < strs.length; i++) { + stmt.setString(offset + i, strs[i]); + } + } + public static void finishSQL(ResultSet rs, Statement stmt) { if (rs != null) { try { |