public class SQLUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static Level |
sSQLLoggingLevel |
| Constructor and Description |
|---|
SQLUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
close(Connection inConn) |
static void |
close(ResultSet inResultSet) |
static void |
close(Statement inStmt) |
static void |
closeResultSetAndStatement(ResultSet inResultSet) |
static boolean |
execute(Connection inConn,
String inSQL) |
static boolean |
execute(PreparedStatement inPreparedStatement) |
static boolean |
execute(Statement inStatement,
String inSQL) |
static ResultSet |
executeQuery(Connection inConn,
String inSQL) |
static ResultSet |
executeQuery(Connection inConn,
String inSQL,
SQLStatementOptions inOptions) |
static int |
executeQuery(PreparedStatement inPreparedStatement) |
static ResultSet |
executeQuery(Statement inStatement,
String inSQL) |
static int |
executeUpdate(Connection inConn,
String inSQL) |
static int |
executeUpdate(PreparedStatement inPreparedStatement) |
static int |
executeUpdate(Statement inStatement,
CharSequence inSQL) |
static Double |
getDouble(ResultSet inResultSet,
DatabaseCol inColumn) |
static Double |
getDouble(ResultSet inResultSet,
int inColumnIndex) |
static Double |
getDouble(ResultSet inResultSet,
String inColumnLabel) |
static Float |
getFloat(ResultSet inResultSet,
DatabaseCol inColumn) |
static Float |
getFloat(ResultSet inResultSet,
int inColumnIndex) |
static Float |
getFloat(ResultSet inResultSet,
String inColumnLabel) |
static Integer |
getInteger(ResultSet inResultSet,
DatabaseCol inColumn) |
static Integer |
getInteger(ResultSet inResultSet,
int inColumnIndex) |
static Integer |
getInteger(ResultSet inResultSet,
String inColumnLabel) |
static Logger |
getLogger() |
static Long |
getLong(ResultSet inResultSet,
DatabaseCol inColumn) |
static Long |
getLong(ResultSet inResultSet,
int inColumnIndex) |
static Long |
getLong(ResultSet inResultSet,
String inColumnLabel) |
static int |
getRowCount(Connection inConn,
DatabaseTable inTable,
Collection<SQLClause> inClauses)
A convenience method for getting a count of rows that meet a specific criteria.
|
static int |
getRowCount(Connection inConn,
DatabaseTable inTable,
WhereClause inWhereClause)
A convenience method for getting a count of rows that meet a specific criteria.
|
static void |
setDate(PreparedStatement inPreparedStatement,
int inIndex,
Date inValue)
A null-tolerant wrapper for PreparedStatement's setDate().
|
static void |
setDate(PreparedStatement inPreparedStatement,
int inIndex,
Date inValue)
A null-tolerant wrapper for PreparedStatement's setDate().
|
static void |
setDouble(PreparedStatement inPreparedStatement,
int inIndex,
Double inValue)
A null-tolerant wrapper for PreparedStatement's setDouble().
|
static void |
setFloat(PreparedStatement inPreparedStatement,
int inIndex,
Float inValue)
A null-tolerant wrapper for PreparedStatement's setFloat().
|
static void |
setInt(PreparedStatement inPreparedStatement,
int inIndex,
Integer inValue)
A null-tolerant wrapper for PreparedStatement's setInt().
|
static void |
setLong(PreparedStatement inPreparedStatement,
int inIndex,
Long inValue)
A null-tolerant wrapper for PreparedStatement's setLong().
|
static void |
setShort(PreparedStatement inPreparedStatement,
int inIndex,
Short inValue)
A null-tolerant wrapper for PreparedStatement's setShort().
|
static void |
setString(PreparedStatement inPreparedStatement,
int inIndex,
String inValue)
A null-tolerant wrapper for PreparedStatement's setString().
|
static void |
setTimestamp(PreparedStatement inPreparedStatement,
int inIndex,
Timestamp inValue)
A null-tolerant wrapper for PreparedStatement's setTimestamp().
|
static List<String> |
splitBatchSQL(Reader inSQL) |
static String |
sqlString(Object inValue) |
static String |
sqlString(String inValue) |
static String |
sqlStringList(Collection<? extends Object> inValues) |
static String |
sqlStringWithDoubleQuotes(String inValue)
All single and double quotes internal to the string are doubled for escaping.
|
public static Level sSQLLoggingLevel
public SQLUtil()
public static String sqlStringWithDoubleQuotes(String inValue)
inValue - the value string to be escaped for single and double quotespublic static String sqlStringList(Collection<? extends Object> inValues)
public static boolean execute(Connection inConn, String inSQL) throws SQLException
SQLExceptionpublic static boolean execute(PreparedStatement inPreparedStatement) throws JDBCException
JDBCExceptionpublic static boolean execute(Statement inStatement, String inSQL) throws JDBCException
JDBCExceptionpublic static int executeUpdate(Connection inConn, String inSQL) throws SQLException
SQLExceptionpublic static int executeUpdate(PreparedStatement inPreparedStatement) throws SQLException
SQLExceptionpublic static int executeUpdate(Statement inStatement, CharSequence inSQL) throws SQLException
SQLExceptionpublic static ResultSet executeQuery(Connection inConn, String inSQL) throws SQLException
SQLExceptionpublic static ResultSet executeQuery(Connection inConn, String inSQL, SQLStatementOptions inOptions) throws SQLException
SQLExceptionpublic static int executeQuery(PreparedStatement inPreparedStatement) throws SQLException
SQLExceptionpublic static ResultSet executeQuery(Statement inStatement, String inSQL) throws JDBCException
JDBCExceptionpublic static void closeResultSetAndStatement(ResultSet inResultSet) throws JDBCException
JDBCExceptionpublic static void close(ResultSet inResultSet) throws JDBCException
JDBCExceptionpublic static void close(Statement inStmt) throws JDBCException
JDBCExceptionpublic static void close(Connection inConn) throws JDBCException
JDBCExceptionpublic static List<String> splitBatchSQL(Reader inSQL) throws IOException
IOExceptionpublic static Integer getInteger(ResultSet inResultSet, String inColumnLabel) throws SQLException
SQLExceptionpublic static Integer getInteger(ResultSet inResultSet, DatabaseCol inColumn) throws SQLException
SQLExceptionpublic static Integer getInteger(ResultSet inResultSet, int inColumnIndex) throws SQLException
SQLExceptionpublic static Long getLong(ResultSet inResultSet, String inColumnLabel) throws SQLException
SQLExceptionpublic static Long getLong(ResultSet inResultSet, DatabaseCol inColumn) throws SQLException
SQLExceptionpublic static Long getLong(ResultSet inResultSet, int inColumnIndex) throws SQLException
SQLExceptionpublic static Float getFloat(ResultSet inResultSet, String inColumnLabel) throws SQLException
SQLExceptionpublic static Float getFloat(ResultSet inResultSet, DatabaseCol inColumn) throws SQLException
SQLExceptionpublic static Float getFloat(ResultSet inResultSet, int inColumnIndex) throws SQLException
SQLExceptionpublic static Double getDouble(ResultSet inResultSet, String inColumnLabel) throws SQLException
SQLExceptionpublic static Double getDouble(ResultSet inResultSet, DatabaseCol inColumn) throws SQLException
SQLExceptionpublic static Double getDouble(ResultSet inResultSet, int inColumnIndex) throws SQLException
SQLExceptionpublic static void setString(PreparedStatement inPreparedStatement, int inIndex, String inValue) throws SQLException
inPreparedStatement - the PreparedStatement in which to set the valueinIndex - the parameter index where the value should be placedinValue - the value to insert into the PreparedStatementSQLExceptionpublic static void setFloat(PreparedStatement inPreparedStatement, int inIndex, Float inValue) throws SQLException
inPreparedStatement - the PreparedStatement in which to set the valueinIndex - the parameter index where the value should be placedinValue - the value to insert into the PreparedStatementSQLExceptionpublic static void setDouble(PreparedStatement inPreparedStatement, int inIndex, Double inValue) throws SQLException
inPreparedStatement - the PreparedStatement in which to set the valueinIndex - the parameter index where the value should be placedinValue - the value to insert into the PreparedStatementSQLExceptionpublic static void setInt(PreparedStatement inPreparedStatement, int inIndex, Integer inValue) throws SQLException
inPreparedStatement - the PreparedStatement in which to set the valueinIndex - the parameter index where the value should be placedinValue - the value to insert into the PreparedStatementSQLExceptionpublic static void setShort(PreparedStatement inPreparedStatement, int inIndex, Short inValue) throws SQLException
inPreparedStatement - the PreparedStatement in which to set the valueinIndex - the parameter index where the value should be placedinValue - the value to insert into the PreparedStatementSQLExceptionpublic static void setLong(PreparedStatement inPreparedStatement, int inIndex, Long inValue) throws SQLException
inPreparedStatement - the PreparedStatement in which to set the valueinIndex - the parameter index where the value should be placedinValue - the value to insert into the PreparedStatementSQLExceptionpublic static void setDate(PreparedStatement inPreparedStatement, int inIndex, Date inValue) throws SQLException
inPreparedStatement - the PreparedStatement in which to set the valueinIndex - the parameter index where the value should be placedinValue - the value to insert into the PreparedStatementSQLExceptionpublic static void setDate(PreparedStatement inPreparedStatement, int inIndex, Date inValue) throws SQLException
inPreparedStatement - the PreparedStatement in which to set the valueinIndex - the parameter index where the value should be placedinValue - the value to insert into the PreparedStatementSQLExceptionpublic static void setTimestamp(PreparedStatement inPreparedStatement, int inIndex, Timestamp inValue) throws SQLException
inPreparedStatement - the PreparedStatement in which to set the valueinIndex - the parameter index where the value should be placedinValue - the value to insert into the PreparedStatementSQLExceptionpublic static int getRowCount(Connection inConn, DatabaseTable inTable, WhereClause inWhereClause) throws SQLException
inConn - the database connectioninTable - the database tableinWhereClause - the where clause to useSQLExceptionpublic static int getRowCount(Connection inConn, DatabaseTable inTable, Collection<SQLClause> inClauses) throws SQLException
inConn - the database connectioninTable - the database tableinClauses - additional clauses to useSQLException
jataylor@hairyfatguy.com