public class JdbcUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static PreparedStatement |
buildStatement(Connection sqlConn,
String query,
String... params)
Build
PreparedStatement from parameters |
static void |
closeConnection(Connection sqlConnection)
Return connection to pool.
|
static void |
closeConnection(Connection sqlConnection,
Boolean previousAutoCommit)
Restore previous
autoCommit setting and return connection to pool. |
static void |
closeResultSet(ResultSet rs)
Close resultset.
|
static void |
closeStatement(PreparedStatement ps)
Utility method to close statement properly.
|
static void |
closeStatement(Statement ps)
Utility method to close statement properly.
|
static void |
executeUpdate(DataSource ds,
String sqlQuery)
Create table based on SQL.
|
static boolean |
isTableExist(DataSource ds,
String tableName)
Check if target Table exist.
|
static void |
rollback(Connection sqlConn)
Utility method to perform rollback in correct way.
|
public static boolean isTableExist(DataSource ds, String tableName)
tableName - table to createpublic static void executeUpdate(DataSource ds, String sqlQuery)
sqlQuery - sql querypublic static PreparedStatement buildStatement(Connection sqlConn, String query, String... params) throws SQLException
PreparedStatement from parametersquery - query templateparams - current parametersPreparedStatementSQLException - sql error when working with statementpublic static void closeResultSet(ResultSet rs)
rs - target resultsetpublic static void closeStatement(PreparedStatement ps)
ps - public static void closeStatement(Statement ps)
ps - public static void closeConnection(Connection sqlConnection, Boolean previousAutoCommit)
autoCommit setting and return connection to pool.sqlConnection - previousAutoCommit - original autoCommit setting of sqlConnection. Ignored when
nullpublic static void closeConnection(Connection sqlConnection)
sqlConnection - public static void rollback(Connection sqlConn)
sqlConn - current sql connectionCopyright © 2013–2017 FF4J. All rights reserved.