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
DatabaseConnectionisAutoCommitSupported in interface DatabaseConnectionSQLExceptionpublic boolean isAutoCommit()
throws SQLException
DatabaseConnectionisAutoCommit in interface DatabaseConnectionSQLExceptionpublic void setAutoCommit(boolean autoCommit)
throws SQLException
DatabaseConnectionsetAutoCommit in interface DatabaseConnectionSQLExceptionpublic Savepoint setSavePoint(String name) throws SQLException
DatabaseConnectionsetSavePoint in interface DatabaseConnectionname - to use for the Savepoint although it can be ignored.SQLExceptionpublic void commit(Savepoint savePoint) throws SQLException
DatabaseConnectioncommit in interface DatabaseConnectionsavePoint - That was returned by setSavePoint or null if none.SQLExceptionpublic void rollback(Savepoint savePoint) throws SQLException
DatabaseConnectionrollback in interface DatabaseConnectionsavePoint - That was returned by setSavePoint previously or null if none.SQLExceptionpublic void releaseSavePoint(Savepoint savePoint) throws SQLException
DatabaseConnectionreleaseSavePoint in interface DatabaseConnectionsavePoint - That was returned by setSavePoint previously or null if none.SQLExceptionpublic int executeStatement(String statementStr, int resultFlags) throws SQLException
DatabaseConnectionexecuteStatement in interface DatabaseConnectionresultFlags - 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.SQLExceptionpublic CompiledStatement compileStatement(String statement, StatementBuilder.StatementType type, FieldType[] argFieldTypes, int resultFlags, boolean cacheStore) throws SQLException
DatabaseConnectioncompileStatement in interface DatabaseConnectionresultFlags - 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.SQLExceptionpublic int insert(String statement, Object[] args, FieldType[] argfieldTypes, GeneratedKeyHolder keyHolder) throws SQLException
DatabaseConnectioninsert in interface DatabaseConnectionstatement - 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.SQLExceptionpublic int update(String statement, Object[] args, FieldType[] argfieldTypes) throws SQLException
DatabaseConnectionupdate in interface DatabaseConnectionstatement - SQL statement to use for updating.args - Object arguments for the SQL '?'s.argfieldTypes - Field types of the arguments.SQLExceptionpublic int delete(String statement, Object[] args, FieldType[] argfieldTypes) throws SQLException
DatabaseConnectiondelete in interface DatabaseConnectionstatement - SQL statement to use for deleting.args - Object arguments for the SQL '?'s.argfieldTypes - Field types of the arguments.SQLExceptionpublic <T> Object queryForOne(String statement, Object[] args, FieldType[] argfieldTypes, GenericRowMapper<T> rowMapper, ObjectCache objectCache) throws SQLException
DatabaseConnectionqueryForOne in interface DatabaseConnectionstatement - 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.SQLExceptionpublic long queryForLong(String statement) throws SQLException
DatabaseConnectionqueryForLong in interface DatabaseConnectionstatement - SQL statement to use for the query.SQLExceptionpublic long queryForLong(String statement, Object[] args, FieldType[] argFieldTypes) throws SQLException
DatabaseConnectionqueryForLong in interface DatabaseConnectionstatement - SQL statement to use for the query.args - Arguments to pass into the query.argFieldTypes - Field types that correspond to the args.SQLExceptionpublic void close()
throws Exception
close in interface AutoCloseableExceptionpublic void closeQuietly()
DatabaseConnectioncloseQuietly in interface DatabaseConnectionpublic boolean isClosed()
throws SQLException
DatabaseConnectionAutoCloseable.close() or because of a fatal error.isClosed in interface DatabaseConnectionSQLExceptionpublic boolean isTableExists(String tableName) throws SQLException
DatabaseConnectionisTableExists in interface DatabaseConnectionSQLExceptionpublic Connection getUnderlyingConnection()
DatabaseConnectiongetUnderlyingConnection in interface DatabaseConnectionThis documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.