public final class PoolUtilities extends Object
Constructor and Description |
---|
PoolUtilities(com.zaxxer.hikari.HikariConfig configuration) |
Modifier and Type | Method and Description |
---|---|
void |
executeSql(Connection connection,
String sql,
boolean isAutoCommit)
Execute the user-specified init SQL.
|
int |
getAndSetNetworkTimeout(Connection connection,
long timeoutMs)
Set the network timeout, if
isUseNetworkTimeout is true and the
driver supports it. |
DataSource |
initializeDataSource(String dsClassName,
DataSource dataSource,
Properties dataSourceProperties,
String jdbcUrl,
String username,
String password)
Create/initialize the underlying DataSource.
|
boolean |
isJdbc4ValidationSupported(Connection connection)
Return true if the driver appears to be JDBC 4.0 compliant.
|
void |
quietlyCloseConnection(Connection connection)
Close connection and eat any exception.
|
void |
setLoginTimeout(DataSource dataSource,
long connectionTimeout)
Set the loginTimeout on the specified DataSource.
|
void |
setNetworkTimeout(Connection connection,
long timeoutMs)
Set the network timeout, if
isUseNetworkTimeout is true and the
driver supports it. |
void |
setQueryTimeout(Statement statement,
int timeoutSec)
Set the query timeout, if it is supported by the driver.
|
void |
setupConnection(Connection connection,
boolean isAutoCommit,
boolean isReadOnly,
int transactionIsolation,
String catalog)
Setup a connection intial state.
|
public void quietlyCloseConnection(Connection connection)
connection
- the connection to closepublic void executeSql(Connection connection, String sql, boolean isAutoCommit) throws SQLException
connection
- the connection to initializesql
- the SQL to executeisAutoCommit
- whether to commit the SQL after execution or notSQLException
- throws if the init SQL execution failspublic DataSource initializeDataSource(String dsClassName, DataSource dataSource, Properties dataSourceProperties, String jdbcUrl, String username, String password)
dsClassName
- a DataSource class name (optional)dataSource
- a DataSource instance (optional)dataSourceProperties
- a Properties instance of DataSource propertiesjdbcUrl
- a JDBC connection URL (optional)username
- a username (optional)password
- a password (optional)public void setupConnection(Connection connection, boolean isAutoCommit, boolean isReadOnly, int transactionIsolation, String catalog) throws SQLException
connection
- a ConnectionisAutoCommit
- auto-commit stateisReadOnly
- read-only statetransactionIsolation
- transaction isolationcatalog
- default catalogSQLException
- thrown from driverpublic boolean isJdbc4ValidationSupported(Connection connection)
connection
- a Connection to checkpublic void setQueryTimeout(Statement statement, int timeoutSec)
statement
- a statement to set the query timeout ontimeoutSec
- the number of seconds before timeoutpublic int getAndSetNetworkTimeout(Connection connection, long timeoutMs)
isUseNetworkTimeout
is true
and the
driver supports it. Return the pre-existing value of the network timeout.connection
- the connection to set the network timeout ontimeoutMs
- the number of milliseconds before timeoutpublic void setNetworkTimeout(Connection connection, long timeoutMs)
isUseNetworkTimeout
is true
and the
driver supports it.connection
- the connection to set the network timeout ontimeoutMs
- the number of milliseconds before timeoutpublic void setLoginTimeout(DataSource dataSource, long connectionTimeout)
dataSource
- the DataSourceconnectionTimeout
- the timeout in millisecondsCopyright © 2015 Zaxxer.com. All Rights Reserved.