aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server/SQLHelpers.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-01-10 16:56:51 +0300
committerGravatar Vitaly Takmazov2016-01-10 16:56:51 +0300
commitc37ed56f884661666b964e47efd23a36be9b24d4 (patch)
tree64917e400d9c97fac185b4f34fd0063314bb7937 /src/main/java/com/juick/server/SQLHelpers.java
parent439d42ef6d60f0a535fdfa2457da8417b70d966a (diff)
logger, diamond and arraylist refactoring
Diffstat (limited to 'src/main/java/com/juick/server/SQLHelpers.java')
-rw-r--r--src/main/java/com/juick/server/SQLHelpers.java25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/main/java/com/juick/server/SQLHelpers.java b/src/main/java/com/juick/server/SQLHelpers.java
index f5569993..13ebe98a 100644
--- a/src/main/java/com/juick/server/SQLHelpers.java
+++ b/src/main/java/com/juick/server/SQLHelpers.java
@@ -9,6 +9,9 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
*
@@ -16,6 +19,8 @@ import java.util.ArrayList;
*/
public class SQLHelpers {
+ private static final Logger logger = Logger.getLogger(SQLHelpers.class.getName());
+
public static int execute(Connection sql, String query) {
int ret = -1;
PreparedStatement stmt = null;
@@ -23,7 +28,7 @@ public class SQLHelpers {
stmt = sql.prepareStatement(query);
ret = stmt.executeUpdate();
} catch (SQLException e) {
- System.err.println(e);
+ logger.log(Level.SEVERE, "sql exception", e);
} finally {
Utils.finishSQL(null, stmt);
}
@@ -38,7 +43,7 @@ public class SQLHelpers {
stmt.setInt(1, param);
ret = stmt.executeUpdate();
} catch (SQLException e) {
- System.err.println(e);
+ logger.log(Level.SEVERE, "sql exception", e);
} finally {
Utils.finishSQL(null, stmt);
}
@@ -56,7 +61,7 @@ public class SQLHelpers {
ret = rs.getInt(1);
}
} catch (SQLException e) {
- System.err.println(e);
+ logger.log(Level.SEVERE, "sql exception", e);
} finally {
Utils.finishSQL(rs, stmt);
}
@@ -75,7 +80,7 @@ public class SQLHelpers {
ret = rs.getInt(1);
}
} catch (SQLException e) {
- System.err.println(e);
+ logger.log(Level.SEVERE, "sql exception", e);
} finally {
Utils.finishSQL(rs, stmt);
}
@@ -94,7 +99,7 @@ public class SQLHelpers {
ret = rs.getInt(1);
}
} catch (SQLException e) {
- System.err.println(e);
+ logger.log(Level.SEVERE, "sql exception", e);
} finally {
Utils.finishSQL(rs, stmt);
}
@@ -113,7 +118,7 @@ public class SQLHelpers {
ret = rs.getString(1);
}
} catch (SQLException e) {
- System.err.println(e);
+ logger.log(Level.SEVERE, "sql exception", e);
} finally {
Utils.finishSQL(rs, stmt);
}
@@ -132,15 +137,15 @@ public class SQLHelpers {
ret = rs.getString(1);
}
} catch (SQLException e) {
- System.err.println(e);
+ logger.log(Level.SEVERE, "sql exception", e);
} finally {
Utils.finishSQL(rs, stmt);
}
return ret;
}
- public static ArrayList<Integer> getArrayInteger(Connection sql, String query, int param) {
- ArrayList<Integer> ret = new ArrayList<Integer>();
+ public static List<Integer> getArrayInteger(Connection sql, String query, int param) {
+ List<Integer> ret = new ArrayList<>();
PreparedStatement stmt = null;
ResultSet rs = null;
@@ -153,7 +158,7 @@ public class SQLHelpers {
ret.add(rs.getInt(1));
}
} catch (SQLException e) {
- System.err.println(e);
+ logger.log(Level.SEVERE, "sql exception", e);
} finally {
Utils.finishSQL(rs, stmt);
}