Class DatabaseConnection

java.lang.Object
net.tirasa.connid.commons.db.DatabaseConnection

public class DatabaseConnection extends Object
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 Details

  • Method Details

    • dispose

      public void dispose()
      Closes the internal Connection.
    • test

      public void test()
      Determines if the underlying JDBC Connection is valid.
      Throws:
      RuntimeException - if the underlying JDBC Connection is not valid otherwise do nothing.
    • getConnection

      public Connection getConnection()
      Get the internal JDBC connection.
      Returns:
      the connection
    • setConnection

      public void setConnection(Connection connection)
      Set the internal JDBC connection.
      Parameters:
      connection - new connection
    • prepareStatement

      public PreparedStatement prepareStatement(String sql, List<SQLParam> params) throws SQLException
      Indirect call of prepare statement with mapped prepare statement parameters
      Parameters:
      sql - a String sql statement definition
      params - the bind parameter values
      Returns:
      return a prepared statement
      Throws:
      SQLException - an exception in statement
    • prepareStatement

      public PreparedStatement prepareStatement(DatabaseQueryBuilder query) throws SQLException
      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

      public CallableStatement prepareCall(String sql, List<SQLParam> params) throws SQLException
      Indirect call of prepareCall statement with mapped callable statement parameters
      Parameters:
      sql - a String sql statement definition
      params - the bind parameter values
      Returns:
      return a callable statement
      Throws:
      SQLException - an exception in statement
    • commit

      public void commit()
      commit transaction