public class DatabaseConnectionProxy extends Object implements DatabaseConnection
See the DatabaseConnectionProxyFactory
javadocs for more details.
DEFAULT_RESULT_FLAGS, MORE_THAN_ONE
Constructor and Description |
---|
DatabaseConnectionProxy(DatabaseConnection proxy) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
closeQuietly()
Close the connection to the database but swallow any exceptions.
|
void |
commit(Savepoint savePoint)
Commit all changes since the savepoint was created.
|
CompiledStatement |
compileStatement(String statement,
StatementBuilder.StatementType type,
FieldType[] argFieldTypes,
int resultFlags,
boolean cacheStore)
Like compileStatement(String, StatementType, FieldType[]) except the caller can specify the result flags.
|
int |
delete(String statement,
Object[] args,
FieldType[] argfieldTypes)
Perform a SQL delete with the associated SQL statement, arguments, and types.
|
int |
executeStatement(String statementStr,
int resultFlags)
Execute a statement directly on the connection.
|
Connection |
getUnderlyingConnection()
Return the underlying database connection so that per-connection calls can be made on it as necessary.
|
int |
insert(String statement,
Object[] args,
FieldType[] argfieldTypes,
GeneratedKeyHolder keyHolder)
Perform a SQL update while with the associated SQL statement, arguments, and types.
|
boolean |
isAutoCommit()
Return if auto-commit is currently enabled.
|
boolean |
isAutoCommitSupported()
Return if auto-commit is supported.
|
boolean |
isClosed()
Return if the connection has been closed either through a call to
AutoCloseable.close() or because of a fatal error. |
boolean |
isTableExists(String tableName)
Return true if the table exists in the database.
|
long |
queryForLong(String statement)
Perform a query whose result should be a single long-integer value.
|
long |
queryForLong(String statement,
Object[] args,
FieldType[] argFieldTypes)
Perform a query whose result should be a single long-integer value.
|
<T> Object |
queryForOne(String statement,
Object[] args,
FieldType[] argfieldTypes,
GenericRowMapper<T> rowMapper,
ObjectCache objectCache)
Perform a SQL query with the associated SQL statement, arguments, and types and returns a single result.
|
void |
releaseSavePoint(Savepoint savePoint)
Release a savepoint when we reach the end of a transaction but not the most outer one.
|
void |
rollback(Savepoint savePoint)
Roll back all changes since the savepoint was created.
|
void |
setAutoCommit(boolean autoCommit)
Set the auto-commit to be on (true) or off (false).
|
Savepoint |
setSavePoint(String name)
Start a save point with a certain name.
|
int |
update(String statement,
Object[] args,
FieldType[] argfieldTypes)
Perform a SQL update with the associated SQL statement, arguments, and types.
|
public DatabaseConnectionProxy(DatabaseConnection proxy)
public boolean isAutoCommitSupported() throws SQLException
DatabaseConnection
isAutoCommitSupported
in interface DatabaseConnection
SQLException
public boolean isAutoCommit() throws SQLException
DatabaseConnection
isAutoCommit
in interface DatabaseConnection
SQLException
public void setAutoCommit(boolean autoCommit) throws SQLException
DatabaseConnection
setAutoCommit
in interface DatabaseConnection
SQLException
public Savepoint setSavePoint(String name) throws SQLException
DatabaseConnection
setSavePoint
in interface DatabaseConnection
name
- to use for the Savepoint although it can be ignored.SQLException
public void commit(Savepoint savePoint) throws SQLException
DatabaseConnection
commit
in interface DatabaseConnection
savePoint
- That was returned by setSavePoint or null if none.SQLException
public void rollback(Savepoint savePoint) throws SQLException
DatabaseConnection
rollback
in interface DatabaseConnection
savePoint
- That was returned by setSavePoint previously or null if none.SQLException
public void releaseSavePoint(Savepoint savePoint) throws SQLException
DatabaseConnection
releaseSavePoint
in interface DatabaseConnection
savePoint
- That was returned by setSavePoint previously or null if none.SQLException
public int executeStatement(String statementStr, int resultFlags) throws SQLException
DatabaseConnection
executeStatement
in interface DatabaseConnection
resultFlags
- Allows specification of some result flags. This is dependent on the backend and database type. Set to
DatabaseConnection.DEFAULT_RESULT_FLAGS
for the internal default.SQLException
public CompiledStatement compileStatement(String statement, StatementBuilder.StatementType type, FieldType[] argFieldTypes, int resultFlags, boolean cacheStore) throws SQLException
DatabaseConnection
compileStatement
in interface DatabaseConnection
resultFlags
- Allows specification of some result flags. This is dependent on the backend and database type. Set to
DatabaseConnection.DEFAULT_RESULT_FLAGS
for the internal default.cacheStore
- Cache can store results from this statement.SQLException
public int insert(String statement, Object[] args, FieldType[] argfieldTypes, GeneratedKeyHolder keyHolder) throws SQLException
DatabaseConnection
insert
in interface DatabaseConnection
statement
- SQL statement to use for inserting.args
- Object arguments for the SQL '?'s.argfieldTypes
- Field types of the arguments.keyHolder
- The holder that gets set with the generated key value which may be null.SQLException
public int update(String statement, Object[] args, FieldType[] argfieldTypes) throws SQLException
DatabaseConnection
update
in interface DatabaseConnection
statement
- SQL statement to use for updating.args
- Object arguments for the SQL '?'s.argfieldTypes
- Field types of the arguments.SQLException
public int delete(String statement, Object[] args, FieldType[] argfieldTypes) throws SQLException
DatabaseConnection
delete
in interface DatabaseConnection
statement
- SQL statement to use for deleting.args
- Object arguments for the SQL '?'s.argfieldTypes
- Field types of the arguments.SQLException
public <T> Object queryForOne(String statement, Object[] args, FieldType[] argfieldTypes, GenericRowMapper<T> rowMapper, ObjectCache objectCache) throws SQLException
DatabaseConnection
queryForOne
in interface DatabaseConnection
statement
- SQL statement to use for deleting.args
- Object arguments for the SQL '?'s.argfieldTypes
- Field types of the arguments.rowMapper
- The mapper to use to convert the row into the returned object.objectCache
- Any object cache associated with the query or null if none.DatabaseConnection.MORE_THAN_ONE
if more than one result was found.SQLException
public long queryForLong(String statement) throws SQLException
DatabaseConnection
queryForLong
in interface DatabaseConnection
statement
- SQL statement to use for the query.SQLException
public long queryForLong(String statement, Object[] args, FieldType[] argFieldTypes) throws SQLException
DatabaseConnection
queryForLong
in interface DatabaseConnection
statement
- SQL statement to use for the query.args
- Arguments to pass into the query.argFieldTypes
- Field types that correspond to the args.SQLException
public void close() throws Exception
close
in interface AutoCloseable
Exception
public void closeQuietly()
DatabaseConnection
closeQuietly
in interface DatabaseConnection
public boolean isClosed() throws SQLException
DatabaseConnection
AutoCloseable.close()
or because of a fatal error.isClosed
in interface DatabaseConnection
SQLException
public boolean isTableExists(String tableName) throws SQLException
DatabaseConnection
isTableExists
in interface DatabaseConnection
SQLException
public Connection getUnderlyingConnection()
DatabaseConnection
getUnderlyingConnection
in interface DatabaseConnection
This documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.