From d5c3d6b5cc0decd1b22cb165f73656aade85e20f Mon Sep 17 00:00:00 2001 From: Ugnich Anton Date: Sun, 13 Apr 2014 13:02:55 +0700 Subject: Utils: buildQueryArray, stmtSetStringArray --- src/com/juick/server/Utils.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/com/juick') 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 { -- cgit v1.2.3