Skip to main content

Database testing

Use SHAFT database actions to open a JDBC connection, execute statements, and attach query evidence to the test report.

See database actions, connection strings, and the Oracle setup.

First useful query test

Start with a read-only query against a disposable schema, containerized database, or in-memory database. Keep credentials outside source control and validate a small result before adding write operations.

SHAFT.DB database = new SHAFT.DB("jdbc:h2:mem:test");
ResultSet rows = database.executeSelectQuery("SELECT 1");

SHAFT.Validations.assertThat().object(rows).isNotNull();

Run the test with Maven:

mvn test

The query, connection target, and validation result are attached to the test report. If the connection fails, verify the JDBC URL, driver dependency, network route, schema permissions, and whether CI has the required secret values.

Choose the next reference

NeedStart with
Build a JDBC URLConnection Strings
Run selects, updates, or result validationDB Actions
Connect to OracleOracle JDBC Setup