- 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
,UPDATE
statements, 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 void
clearWarnings()
void
close()
void
commit()
Statement
createStatement()
Statement
createStatement(int resultSetType, int resultSetConcurrency)
Statement
createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
boolean
getAutoCommit()
String
getCatalog()
Properties
getClientInfo()
String
getClientInfo(String name)
int
getHoldability()
int
getTransactionIsolation()
Map<String,Class<?>>
getTypeMap()
SQLWarning
getWarnings()
boolean
isReadOnly()
boolean
isValid(int timeout)
boolean
isWrapperFor(Class<?> iface)
CallableStatement
prepareCall(String sql)
CallableStatement
prepareCall(String sql, int resultSetType, int resultSetConcurrency)
CallableStatement
prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
PreparedStatement
prepareStatement(String sql)
PreparedStatement
prepareStatement(String sql, int autoGeneratedKeys)
PreparedStatement
prepareStatement(String sql, int[] columnIndexes)
PreparedStatement
prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
PreparedStatement
prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
PreparedStatement
prepareStatement(String sql, String[] columnNames)
void
releaseSavepoint(Savepoint savepoint)
void
rollback()
void
rollback(Savepoint savepoint)
void
setAutoCommit(boolean autoCommit)
void
setCatalog(String catalog)
void
setClientInfo(String name, String value)
void
setClientInfo(Properties properties)
void
setHoldability(int holdability)
void
setReadOnly(boolean readOnly)
Savepoint
setSavepoint()
Savepoint
setSavepoint(String name)
void
setTransactionIsolation(int level)
void
setTypeMap(Map<String,Class<?>> map)
<T> T
unwrap(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:
unwrap
in interfaceWrapper
- Overrides:
unwrap
in classDefaultConnection
- Throws:
SQLException
-
isWrapperFor
public boolean isWrapperFor(Class<?> iface) throws SQLException
- Specified by:
isWrapperFor
in interfaceWrapper
- Overrides:
isWrapperFor
in classDefaultConnection
- Throws:
SQLException
-
createStatement
public Statement createStatement() throws SQLException
- Specified by:
createStatement
in interfaceConnection
- Overrides:
createStatement
in classDefaultConnection
- Throws:
SQLException
-
createStatement
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
- Specified by:
createStatement
in interfaceConnection
- Overrides:
createStatement
in classDefaultConnection
- Throws:
SQLException
-
createStatement
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- Specified by:
createStatement
in interfaceConnection
- Overrides:
createStatement
in classDefaultConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Overrides:
prepareStatement
in classDefaultConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Overrides:
prepareStatement
in classDefaultConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Overrides:
prepareStatement
in classDefaultConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Overrides:
prepareStatement
in classDefaultConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Overrides:
prepareStatement
in classDefaultConnection
- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql) throws SQLException
- Specified by:
prepareCall
in interfaceConnection
- Overrides:
prepareCall
in classDefaultConnection
- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
- Specified by:
prepareCall
in interfaceConnection
- Overrides:
prepareCall
in classDefaultConnection
- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- Specified by:
prepareCall
in interfaceConnection
- Overrides:
prepareCall
in classDefaultConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Overrides:
prepareStatement
in classDefaultConnection
- Throws:
SQLException
-
commit
public void commit() throws SQLException
- Specified by:
commit
in interfaceConnection
- Overrides:
commit
in classDefaultConnection
- Throws:
SQLException
-
rollback
public void rollback() throws SQLException
- Specified by:
rollback
in interfaceConnection
- Overrides:
rollback
in classDefaultConnection
- Throws:
SQLException
-
rollback
public void rollback(Savepoint savepoint) throws SQLException
- Specified by:
rollback
in interfaceConnection
- Overrides:
rollback
in classDefaultConnection
- Throws:
SQLException
-
close
public void close() throws SQLException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceConnection
- Overrides:
close
in classDefaultConnection
- Throws:
SQLException
-
setSavepoint
public Savepoint setSavepoint() throws SQLException
- Specified by:
setSavepoint
in interfaceConnection
- Overrides:
setSavepoint
in classDefaultConnection
- Throws:
SQLException
-
setSavepoint
public Savepoint setSavepoint(String name) throws SQLException
- Specified by:
setSavepoint
in interfaceConnection
- Overrides:
setSavepoint
in classDefaultConnection
- Throws:
SQLException
-
releaseSavepoint
public void releaseSavepoint(Savepoint savepoint) throws SQLException
- Specified by:
releaseSavepoint
in interfaceConnection
- Overrides:
releaseSavepoint
in classDefaultConnection
- Throws:
SQLException
-
setAutoCommit
public void setAutoCommit(boolean autoCommit) throws SQLException
- Specified by:
setAutoCommit
in interfaceConnection
- Overrides:
setAutoCommit
in classDefaultConnection
- Throws:
SQLException
-
getAutoCommit
public boolean getAutoCommit() throws SQLException
- Specified by:
getAutoCommit
in interfaceConnection
- Overrides:
getAutoCommit
in classDefaultConnection
- Throws:
SQLException
-
setReadOnly
public void setReadOnly(boolean readOnly) throws SQLException
- Specified by:
setReadOnly
in interfaceConnection
- Overrides:
setReadOnly
in classDefaultConnection
- Throws:
SQLException
-
isReadOnly
public boolean isReadOnly() throws SQLException
- Specified by:
isReadOnly
in interfaceConnection
- Overrides:
isReadOnly
in classDefaultConnection
- Throws:
SQLException
-
setCatalog
public void setCatalog(String catalog) throws SQLException
- Specified by:
setCatalog
in interfaceConnection
- Overrides:
setCatalog
in classDefaultConnection
- Throws:
SQLException
-
getCatalog
public String getCatalog() throws SQLException
- Specified by:
getCatalog
in interfaceConnection
- Overrides:
getCatalog
in classDefaultConnection
- Throws:
SQLException
-
getWarnings
public SQLWarning getWarnings() throws SQLException
- Specified by:
getWarnings
in interfaceConnection
- Overrides:
getWarnings
in classDefaultConnection
- Throws:
SQLException
-
clearWarnings
public void clearWarnings() throws SQLException
- Specified by:
clearWarnings
in interfaceConnection
- Overrides:
clearWarnings
in classDefaultConnection
- Throws:
SQLException
-
setTransactionIsolation
public void setTransactionIsolation(int level) throws SQLException
- Specified by:
setTransactionIsolation
in interfaceConnection
- Overrides:
setTransactionIsolation
in classDefaultConnection
- Throws:
SQLException
-
getTransactionIsolation
public int getTransactionIsolation() throws SQLException
- Specified by:
getTransactionIsolation
in interfaceConnection
- Overrides:
getTransactionIsolation
in classDefaultConnection
- Throws:
SQLException
-
setTypeMap
public void setTypeMap(Map<String,Class<?>> map) throws SQLException
- Specified by:
setTypeMap
in interfaceConnection
- Overrides:
setTypeMap
in classDefaultConnection
- Throws:
SQLException
-
getTypeMap
public Map<String,Class<?>> getTypeMap() throws SQLException
- Specified by:
getTypeMap
in interfaceConnection
- Overrides:
getTypeMap
in classDefaultConnection
- Throws:
SQLException
-
setHoldability
public void setHoldability(int holdability) throws SQLException
- Specified by:
setHoldability
in interfaceConnection
- Overrides:
setHoldability
in classDefaultConnection
- Throws:
SQLException
-
getHoldability
public int getHoldability() throws SQLException
- Specified by:
getHoldability
in interfaceConnection
- Overrides:
getHoldability
in classDefaultConnection
- Throws:
SQLException
-
isValid
public boolean isValid(int timeout) throws SQLException
- Specified by:
isValid
in interfaceConnection
- Overrides:
isValid
in classDefaultConnection
- Throws:
SQLException
-
setClientInfo
public void setClientInfo(String name, String value) throws SQLClientInfoException
- Specified by:
setClientInfo
in interfaceConnection
- Overrides:
setClientInfo
in classDefaultConnection
- Throws:
SQLClientInfoException
-
setClientInfo
public void setClientInfo(Properties properties) throws SQLClientInfoException
- Specified by:
setClientInfo
in interfaceConnection
- Overrides:
setClientInfo
in classDefaultConnection
- Throws:
SQLClientInfoException
-
getClientInfo
public String getClientInfo(String name) throws SQLException
- Specified by:
getClientInfo
in interfaceConnection
- Overrides:
getClientInfo
in classDefaultConnection
- Throws:
SQLException
-
getClientInfo
public Properties getClientInfo() throws SQLException
- Specified by:
getClientInfo
in interfaceConnection
- Overrides:
getClientInfo
in classDefaultConnection
- Throws:
SQLException
-
-