public interface DatabaseConnection extends AutoCloseable
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_RESULT_FLAGS |
static Object |
MORE_THAN_ONE
returned by
queryForOne(java.lang.String, java.lang.Object[], com.j256.ormlite.field.FieldType[], com.j256.ormlite.stmt.GenericRowMapper<T>, com.j256.ormlite.dao.ObjectCache) if more than one result was found by the query |
Modifier and Type | Method and Description |
---|---|
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 savePointName)
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.
|
close
static final Object MORE_THAN_ONE
queryForOne(java.lang.String, java.lang.Object[], com.j256.ormlite.field.FieldType[], com.j256.ormlite.stmt.GenericRowMapper<T>, com.j256.ormlite.dao.ObjectCache)
if more than one result was found by the querystatic final int DEFAULT_RESULT_FLAGS
boolean isAutoCommitSupported() throws SQLException
SQLException
boolean isAutoCommit() throws SQLException
SQLException
void setAutoCommit(boolean autoCommit) throws SQLException
SQLException
Savepoint setSavePoint(String savePointName) throws SQLException
savePointName
- to use for the Savepoint although it can be ignored.SQLException
void commit(Savepoint savePoint) throws SQLException
savePoint
- That was returned by setSavePoint or null if none.SQLException
void rollback(Savepoint savePoint) throws SQLException
savePoint
- That was returned by setSavePoint previously or null if none.SQLException
void releaseSavePoint(Savepoint savePoint) throws SQLException
savePoint
- That was returned by setSavePoint previously or null if none.SQLException
int executeStatement(String statementStr, int resultFlags) throws SQLException
resultFlags
- Allows specification of some result flags. This is dependent on the backend and database type. Set to
DEFAULT_RESULT_FLAGS
for the internal default.SQLException
CompiledStatement compileStatement(String statement, StatementBuilder.StatementType type, FieldType[] argFieldTypes, int resultFlags, boolean cacheStore) throws SQLException
resultFlags
- Allows specification of some result flags. This is dependent on the backend and database type. Set to
DEFAULT_RESULT_FLAGS
for the internal default.cacheStore
- Cache can store results from this statement.SQLException
int insert(String statement, Object[] args, FieldType[] argfieldTypes, GeneratedKeyHolder keyHolder) throws SQLException
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
int update(String statement, Object[] args, FieldType[] argfieldTypes) throws SQLException
statement
- SQL statement to use for updating.args
- Object arguments for the SQL '?'s.argfieldTypes
- Field types of the arguments.SQLException
int delete(String statement, Object[] args, FieldType[] argfieldTypes) throws SQLException
statement
- SQL statement to use for deleting.args
- Object arguments for the SQL '?'s.argfieldTypes
- Field types of the arguments.SQLException
<T> Object queryForOne(String statement, Object[] args, FieldType[] argfieldTypes, GenericRowMapper<T> rowMapper, ObjectCache objectCache) throws SQLException
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.MORE_THAN_ONE
if more than one result was found.SQLException
long queryForLong(String statement) throws SQLException
statement
- SQL statement to use for the query.SQLException
long queryForLong(String statement, Object[] args, FieldType[] argFieldTypes) throws SQLException
statement
- SQL statement to use for the query.args
- Arguments to pass into the query.argFieldTypes
- Field types that correspond to the args.SQLException
void closeQuietly()
boolean isClosed() throws SQLException
AutoCloseable.close()
or because of a fatal error.SQLException
boolean isTableExists(String tableName) throws SQLException
SQLException
Connection getUnderlyingConnection()
This documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.