Package net.tirasa.connid.commons.db
Class DatabaseConnection
java.lang.Object
net.tirasa.connid.commons.db.DatabaseConnection
The DatabaseConnection wraps the JDBC connection.
Define the test method meaning the wrapped connection is still valid
Defines come useful method to work with prepared statements *
-
Constructor Summary
ConstructorDescriptionDatabaseConnection
(Connection conn) Use theConfiguration
passed in to immediately connect to a database. -
Method Summary
Modifier and TypeMethodDescriptionvoid
commit()
commit transactionvoid
dispose()
Closes the internalConnection
.Get the internal JDBC connection.prepareCall
(String sql, List<SQLParam> params) Indirect call of prepareCall statement with mapped callable statement parametersprepareStatement
(String sql, List<SQLParam> params) Indirect call of prepare statement with mapped prepare statement parametersIndirect call of prepare statement using the query builder objectvoid
setConnection
(Connection connection) Set the internal JDBC connection.void
test()
Determines if the underlying JDBCConnection
is valid.
-
Constructor Details
-
DatabaseConnection
Use theConfiguration
passed in to immediately connect to a database. If theConnection
fails aRuntimeException
will be thrown.- Parameters:
conn
- a connection- Throws:
RuntimeException
- if there is a problem creating aConnection
.
-
-
Method Details
-
dispose
public void dispose()Closes the internalConnection
. -
test
public void test()Determines if the underlying JDBCConnection
is valid.- Throws:
RuntimeException
- if the underlying JDBCConnection
is not valid otherwise do nothing.
-
getConnection
Get the internal JDBC connection.- Returns:
- the connection
-
setConnection
Set the internal JDBC connection.- Parameters:
connection
- new connection
-
prepareStatement
Indirect call of prepare statement with mapped prepare statement parameters- Parameters:
sql
- aString
sql statement definitionparams
- the bind parameter values- Returns:
- return a prepared statement
- Throws:
SQLException
- an exception in statement
-
prepareStatement
Indirect call of prepare statement using the query builder object- Parameters:
query
- DatabaseQueryBuilder query- Returns:
- return a prepared statement
- Throws:
SQLException
- an exception in statement
-
prepareCall
Indirect call of prepareCall statement with mapped callable statement parameters- Parameters:
sql
- aString
sql statement definitionparams
- the bind parameter values- Returns:
- return a callable statement
- Throws:
SQLException
- an exception in statement
-
commit
public void commit()commit transaction
-