- java.lang.Object
-
- org.jooq.tools.jdbc.JDBC41Connection
-
- org.jooq.tools.jdbc.DefaultConnection
-
- org.jooq.tools.jdbc.BatchedConnection
-
- All Implemented Interfaces:
AutoCloseable,Connection,Wrapper
public class BatchedConnection extends DefaultConnection
A batching connection.This connection buffers consecutive identical prepared statements for
DELETE,INSERT,MERGE,UPDATEstatements, instead of allowing for them to be executed directly.Calls to
PreparedStatement.executeUpdate()orPreparedStatement.execute()are replaced byPreparedStatement.addBatch(). The update count of such operations is always zero, and cannot be retrieved later on. When any of the following events happen, the batch is executed usingStatement.executeBatch():- The
close()method is called (the call is not delegated to the wrapped connection). - A
Connection.prepareStatement(String)call is made with a different SQL string. - Any other type of statement is created or other API is called, such as
commit().
- Author:
- Lukas Eder
-
-
Field Summary
-
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
-
-
Constructor Summary
Constructors Constructor Description BatchedConnection(Connection delegate)BatchedConnection(Connection delegate, int batchSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearWarnings()voidclose()voidcommit()StatementcreateStatement()StatementcreateStatement(int resultSetType, int resultSetConcurrency)StatementcreateStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)booleangetAutoCommit()StringgetCatalog()PropertiesgetClientInfo()StringgetClientInfo(String name)intgetHoldability()intgetTransactionIsolation()Map<String,Class<?>>getTypeMap()SQLWarninggetWarnings()booleanisReadOnly()booleanisValid(int timeout)booleanisWrapperFor(Class<?> iface)CallableStatementprepareCall(String sql)CallableStatementprepareCall(String sql, int resultSetType, int resultSetConcurrency)CallableStatementprepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)PreparedStatementprepareStatement(String sql)PreparedStatementprepareStatement(String sql, int autoGeneratedKeys)PreparedStatementprepareStatement(String sql, int[] columnIndexes)PreparedStatementprepareStatement(String sql, int resultSetType, int resultSetConcurrency)PreparedStatementprepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)PreparedStatementprepareStatement(String sql, String[] columnNames)voidreleaseSavepoint(Savepoint savepoint)voidrollback()voidrollback(Savepoint savepoint)voidsetAutoCommit(boolean autoCommit)voidsetCatalog(String catalog)voidsetClientInfo(String name, String value)voidsetClientInfo(Properties properties)voidsetHoldability(int holdability)voidsetReadOnly(boolean readOnly)SavepointsetSavepoint()SavepointsetSavepoint(String name)voidsetTransactionIsolation(int level)voidsetTypeMap(Map<String,Class<?>> map)<T> Tunwrap(Class<T> iface)-
Methods inherited from class org.jooq.tools.jdbc.DefaultConnection
abort, beginRequest, createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStruct, endRequest, getDelegate, getMetaData, getNetworkTimeout, getSchema, isClosed, nativeSQL, setNetworkTimeout, setSchema, setShardingKey, setShardingKey, setShardingKeyIfValid, setShardingKeyIfValid
-
-
-
-
Constructor Detail
-
BatchedConnection
public BatchedConnection(Connection delegate)
-
BatchedConnection
public BatchedConnection(Connection delegate, int batchSize)
-
-
Method Detail
-
unwrap
public <T> T unwrap(Class<T> iface) throws SQLException
- Specified by:
unwrapin interfaceWrapper- Overrides:
unwrapin classDefaultConnection- Throws:
SQLException
-
isWrapperFor
public boolean isWrapperFor(Class<?> iface) throws SQLException
- Specified by:
isWrapperForin interfaceWrapper- Overrides:
isWrapperForin classDefaultConnection- Throws:
SQLException
-
createStatement
public Statement createStatement() throws SQLException
- Specified by:
createStatementin interfaceConnection- Overrides:
createStatementin classDefaultConnection- Throws:
SQLException
-
createStatement
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
- Specified by:
createStatementin interfaceConnection- Overrides:
createStatementin classDefaultConnection- Throws:
SQLException
-
createStatement
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- Specified by:
createStatementin interfaceConnection- Overrides:
createStatementin classDefaultConnection- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
- Specified by:
prepareStatementin interfaceConnection- Overrides:
prepareStatementin classDefaultConnection- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- Specified by:
prepareStatementin interfaceConnection- Overrides:
prepareStatementin classDefaultConnection- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
- Specified by:
prepareStatementin interfaceConnection- Overrides:
prepareStatementin classDefaultConnection- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
- Specified by:
prepareStatementin interfaceConnection- Overrides:
prepareStatementin classDefaultConnection- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
- Specified by:
prepareStatementin interfaceConnection- Overrides:
prepareStatementin classDefaultConnection- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql) throws SQLException
- Specified by:
prepareCallin interfaceConnection- Overrides:
prepareCallin classDefaultConnection- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
- Specified by:
prepareCallin interfaceConnection- Overrides:
prepareCallin classDefaultConnection- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- Specified by:
prepareCallin interfaceConnection- Overrides:
prepareCallin classDefaultConnection- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql) throws SQLException
- Specified by:
prepareStatementin interfaceConnection- Overrides:
prepareStatementin classDefaultConnection- Throws:
SQLException
-
commit
public void commit() throws SQLException- Specified by:
commitin interfaceConnection- Overrides:
commitin classDefaultConnection- Throws:
SQLException
-
rollback
public void rollback() throws SQLException- Specified by:
rollbackin interfaceConnection- Overrides:
rollbackin classDefaultConnection- Throws:
SQLException
-
rollback
public void rollback(Savepoint savepoint) throws SQLException
- Specified by:
rollbackin interfaceConnection- Overrides:
rollbackin classDefaultConnection- Throws:
SQLException
-
close
public void close() throws SQLException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceConnection- Overrides:
closein classDefaultConnection- Throws:
SQLException
-
setSavepoint
public Savepoint setSavepoint() throws SQLException
- Specified by:
setSavepointin interfaceConnection- Overrides:
setSavepointin classDefaultConnection- Throws:
SQLException
-
setSavepoint
public Savepoint setSavepoint(String name) throws SQLException
- Specified by:
setSavepointin interfaceConnection- Overrides:
setSavepointin classDefaultConnection- Throws:
SQLException
-
releaseSavepoint
public void releaseSavepoint(Savepoint savepoint) throws SQLException
- Specified by:
releaseSavepointin interfaceConnection- Overrides:
releaseSavepointin classDefaultConnection- Throws:
SQLException
-
setAutoCommit
public void setAutoCommit(boolean autoCommit) throws SQLException- Specified by:
setAutoCommitin interfaceConnection- Overrides:
setAutoCommitin classDefaultConnection- Throws:
SQLException
-
getAutoCommit
public boolean getAutoCommit() throws SQLException- Specified by:
getAutoCommitin interfaceConnection- Overrides:
getAutoCommitin classDefaultConnection- Throws:
SQLException
-
setReadOnly
public void setReadOnly(boolean readOnly) throws SQLException- Specified by:
setReadOnlyin interfaceConnection- Overrides:
setReadOnlyin classDefaultConnection- Throws:
SQLException
-
isReadOnly
public boolean isReadOnly() throws SQLException- Specified by:
isReadOnlyin interfaceConnection- Overrides:
isReadOnlyin classDefaultConnection- Throws:
SQLException
-
setCatalog
public void setCatalog(String catalog) throws SQLException
- Specified by:
setCatalogin interfaceConnection- Overrides:
setCatalogin classDefaultConnection- Throws:
SQLException
-
getCatalog
public String getCatalog() throws SQLException
- Specified by:
getCatalogin interfaceConnection- Overrides:
getCatalogin classDefaultConnection- Throws:
SQLException
-
getWarnings
public SQLWarning getWarnings() throws SQLException
- Specified by:
getWarningsin interfaceConnection- Overrides:
getWarningsin classDefaultConnection- Throws:
SQLException
-
clearWarnings
public void clearWarnings() throws SQLException- Specified by:
clearWarningsin interfaceConnection- Overrides:
clearWarningsin classDefaultConnection- Throws:
SQLException
-
setTransactionIsolation
public void setTransactionIsolation(int level) throws SQLException- Specified by:
setTransactionIsolationin interfaceConnection- Overrides:
setTransactionIsolationin classDefaultConnection- Throws:
SQLException
-
getTransactionIsolation
public int getTransactionIsolation() throws SQLException- Specified by:
getTransactionIsolationin interfaceConnection- Overrides:
getTransactionIsolationin classDefaultConnection- Throws:
SQLException
-
setTypeMap
public void setTypeMap(Map<String,Class<?>> map) throws SQLException
- Specified by:
setTypeMapin interfaceConnection- Overrides:
setTypeMapin classDefaultConnection- Throws:
SQLException
-
getTypeMap
public Map<String,Class<?>> getTypeMap() throws SQLException
- Specified by:
getTypeMapin interfaceConnection- Overrides:
getTypeMapin classDefaultConnection- Throws:
SQLException
-
setHoldability
public void setHoldability(int holdability) throws SQLException- Specified by:
setHoldabilityin interfaceConnection- Overrides:
setHoldabilityin classDefaultConnection- Throws:
SQLException
-
getHoldability
public int getHoldability() throws SQLException- Specified by:
getHoldabilityin interfaceConnection- Overrides:
getHoldabilityin classDefaultConnection- Throws:
SQLException
-
isValid
public boolean isValid(int timeout) throws SQLException- Specified by:
isValidin interfaceConnection- Overrides:
isValidin classDefaultConnection- Throws:
SQLException
-
setClientInfo
public void setClientInfo(String name, String value) throws SQLClientInfoException
- Specified by:
setClientInfoin interfaceConnection- Overrides:
setClientInfoin classDefaultConnection- Throws:
SQLClientInfoException
-
setClientInfo
public void setClientInfo(Properties properties) throws SQLClientInfoException
- Specified by:
setClientInfoin interfaceConnection- Overrides:
setClientInfoin classDefaultConnection- Throws:
SQLClientInfoException
-
getClientInfo
public String getClientInfo(String name) throws SQLException
- Specified by:
getClientInfoin interfaceConnection- Overrides:
getClientInfoin classDefaultConnection- Throws:
SQLException
-
getClientInfo
public Properties getClientInfo() throws SQLException
- Specified by:
getClientInfoin interfaceConnection- Overrides:
getClientInfoin classDefaultConnection- Throws:
SQLException
-
-