@since: 1.0 > @api-version: 2.0 > Dependencies: Hibernate | Commons DBCP2


DatabaseActions implements a direct JDBC access to the configured DBMS. This allows to send direct SQL statements out of the DAO. The connection pool DBCP2 holds the database connection alive and optimize the performance of the whole application. Commons DBCP2 is the same connection pool which is used in the configuration for the DAO.

Configuration Items: see here for all configuration values

  • jdbc.schema = together
  • jdbc.user = together
  • jdbc.password = together
  • hibernate.timezone = UTC
  • = update
  • hibernate.show_sql = false
  • dbcp.initialSize = 10
  • hibernate.dialect.database = org.hibernate.dialect.PostgreSQL95Dialect
  • jdbc.driverClassName = org.postgresql.Driver
  • jdbc.url = jdbc:postgresql://


DatabaseActions dbms = new JdbcActions();
// establish connection

// execute a simple SQL statement
dbms.executeQuery("DROP TABLE IF EXISTS test;");

// execute a SQL file from classpath

// get DBMS connection information
JdbcConnection metaData = dbms.getJdbcMetaData();

The DatabaseActions are very helpful by dealing with test cases. It is possible to create a connection and execute SQL scripts to populate the database tables with test values. Inside the package is placed a file called which is configured as fall back when the property file for connect(“”) is an empty String or set to test. The pre configured Database (PostgreSQL) connection is: user=together, password=together and schema=togehter-test.

Usage in test cases:

public class JUnit5Test {

    private static DatabaseActions jdbcActions = new JdbcActions();

    private final String SQL_FILE
            = "org/europa/together/sql/test.sql";
    private final String sql_drop = "DROP TABLE IF EXISTS test;";

    static void setUp() {
        //only when a JDBC connection is established the test suite will executed

    void testCaseTermination() {
        //clean up database after test done

    void foo() {
        // populate database with sql script

        do something ...