Interface DatabaseActions

All Known Implementing Classes:
JdbcActions

@API(status=STABLE, since="1.0", consumers="JdbcActions") @Component public interface DatabaseActions
DatabaseActions is a simple helper class to execute SQL queries and other database operations out of the DAO Context. To establish a JDBC connection for unit tests call the constructor:
DatabaseActions(boolean activateTestMode);
Since:
1.0
Version:
2.0
Author:
elmar.dott@gmail.com
  • Field Details

    • FEATURE_ID

      @API(status=STABLE, since="1.2") static final String FEATURE_ID
      Identifier for the given feature.
      See Also:
  • Method Details

    • connect

      @API(status=STABLE, since="1.0") boolean connect(String propertyFile)
      Establish an JDBC connection. If the propertyFile parameter is empty, then the method load by default the configuration from the classpath. The path to the external property file have to be relative to the execution path.
      Parameters:
      propertyFile - as String
      Returns:
      true on success
    • executeQuery

      @API(status=STABLE, since="3.0") ResultSet executeQuery(String sql) throws SQLException
      Execute a plain SQL query and get the ResultSet. If there exist multiple SELECT statements, then the ResultSet contains only the rusultSet of the last SELECT statement.
      Parameters:
      sql - as String
      Returns:
      result as ResultSet
      Throws:
      SQLException
    • executeSqlFromClasspath

      @API(status=STABLE, since="1.0") boolean executeSqlFromClasspath(String sqlFile)
      Load an SQL file from the classpath and execute the script. Attention: This function should be used to populate a database and so on. It is not designed to handle multiple ResultSets by using SELECT. If multiple SELECT statements appears in an SQL file, then only the ResultSet of the last SELECT statement will be available.
      Internal call this function for each single SQL statement the executeQuery() method.
      Parameters:
      sqlFile - as String
      Returns:
      true on success
    • countResultSets

      @API(status=STABLE, since="3.0") int countResultSets(ResultSet results) throws SQLException
      Count the size of a ResultSet.
      Parameters:
      results - as ResultSet
      Returns:
      count the results
      Throws:
      SQLException
    • getJdbcMetaData

      @API(status=STABLE, since="3.0") JdbcConnection getJdbcMetaData() throws SQLException
      Return a object with all JDBC connection meta date.
      Returns:
      JdbcConnection as Object
      Throws:
      SQLException