From 13a861563ffead4cadba48e523aad2e5c6beb44c Mon Sep 17 00:00:00 2001 From: Ugnich Anton Date: Fri, 25 Jul 2014 00:16:47 +0700 Subject: AdsQueries for unauthorized --- src/com/juick/server/SQLHelpers.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/com/juick/server/SQLHelpers.java') diff --git a/src/com/juick/server/SQLHelpers.java b/src/com/juick/server/SQLHelpers.java index 28ccdb8c..f5569993 100644 --- a/src/com/juick/server/SQLHelpers.java +++ b/src/com/juick/server/SQLHelpers.java @@ -45,6 +45,24 @@ public class SQLHelpers { return ret; } + public static int getInt(Connection sql, String query, int defvalue) { + int ret = defvalue; + PreparedStatement stmt = null; + ResultSet rs = null; + try { + stmt = sql.prepareStatement(query); + rs = stmt.executeQuery(); + if (rs.first()) { + ret = rs.getInt(1); + } + } catch (SQLException e) { + System.err.println(e); + } finally { + Utils.finishSQL(rs, stmt); + } + return ret; + } + public static int getInt(Connection sql, String query, int param, int defvalue) { int ret = defvalue; PreparedStatement stmt = null; -- cgit v1.2.3