List of utility methods to do SQL PreparedStatement
PreparedStatement | getPreparedStatement(Connection conn, String sql, List get Prepared Statement PreparedStatement pstmt = getGeneratedKeys ? conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS) : conn.prepareStatement(sql); int pos = 1; for (Object param : sqlParams) { if (param instanceof Integer) { pstmt.setInt(pos++, ((Integer) param).intValue()); } else { pstmt.setString(pos++, (String) param); ... |
PreparedStatement | getPreparedStatement(String sql) Get prepared statement try { Connection conn = getConnection(); PreparedStatement pstmt = conn.prepareStatement(sql); statConns.put(pstmt, conn); return pstmt; } catch (Exception e) { return null; |
int | getPriorID(Connection conn, PreparedStatement stmt) get Prior ID int back = -1; if (uri.startsWith("jdbc:hsqldb")) { PreparedStatement ident = conn.prepareStatement("CALL IDENTITY()"); ResultSet res = ident.executeQuery(); if (res.next()) { back = res.getInt(1); res.close(); ... |
int | getScalarValue(PreparedStatement ps) Get a scalar value from a PreparedStatement. ResultSet rs = ps.executeQuery(); rs.next(); try { return rs.getInt(1); } finally { close(rs); close(ps); |
void | importCsvDataInTable(int offsetIndex, Connection connection, PreparedStatement preparedStatement, String[] columnMapping, List
import Csv Data In Table int csvLineIndex = offsetIndex; for (List<String> csvLine : data) { csvLineIndex++; if (csvLine.size() != columnMapping.length) { notInsertedData.put(csvLineIndex, csvLine); } else { int parameterIndex = 1; for (int csvValueIndex = 0; csvValueIndex < csvLine.size(); csvValueIndex++) { ... |
Array | intToArray(final int[] arr) Converts an array of integers to an Array object that can be used in a PreparedStatement for Postgresql to set an int4[] column. return intToArray(arr, "int4"); |
boolean | isClosed(PreparedStatement ps, boolean defaultValue) is Closed try { return ps.isClosed(); } catch (Throwable t) { return defaultValue; |
List | loadColumnTableNameList(PreparedStatement stmt) Return table name list which is related on columns. List<String> tableNames = new ArrayList<String>(); try { ResultSetMetaData rsMetaData = stmt.getMetaData(); if (rsMetaData != null) { for (int i = 1; i <= rsMetaData.getColumnCount(); i++) { tableNames.add(rsMetaData.getTableName(i)); } catch (Exception ignored) { return tableNames; |
void | LockRow(PreparedStatement pstmt, String tablename, boolean exclusiveMode) Lock Row pstmt.executeUpdate(getLockStatement(tablename, exclusiveMode)); |
void | logPreparedStatement(PreparedStatement p) log Prepared Statement System.out.println("[QUERY] : " + p.toString().split(": ")[1]); |