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
ConstructorsConstructorDescriptionDatabaseConnection(Connection conn) Use theConfigurationpassed in to immediately connect to a database. -
Method Summary
Modifier and TypeMethodDescriptionvoidcommit()commit transactionvoiddispose()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 objectvoidsetConnection(Connection connection) Set the internal JDBC connection.voidtest()Determines if the underlying JDBCConnectionis valid.
-
Constructor Details
-
DatabaseConnection
Use theConfigurationpassed in to immediately connect to a database. If theConnectionfails aRuntimeExceptionwill 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 JDBCConnectionis valid.- Throws:
RuntimeException- if the underlying JDBCConnectionis 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- aStringsql 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- aStringsql statement definitionparams- the bind parameter values- Returns:
- return a callable statement
- Throws:
SQLException- an exception in statement
-
commit
public void commit()commit transaction
-