This document explains how to set up and run IBM DB2 Database tests with OJP.
- Docker - Required to run IBM DB2 locally
- IBM DB2 JDBC Driver - Must be downloaded and placed in
ojp-libsfolder
Use the official IBM DB2 image for testing:
docker pull icr.io/db2_community/db2After pulling:
docker run -d --name ojp-db2 --privileged -p 50000:50000 -m 6g -e LICENSE=accept -e DB2INSTANCE=db2inst1 -e DB2INST1_PASSWORD=testpass -e DBNAME=testdb icr.io/db2_community/db2Wait for the database to fully start (may take several minutes). You can check the logs:
docker logs db2
⚠️ For Version 0.4.0-beta and Later:
JDBC drivers are no longer added to pom.xml. Instead, download the driver and place it in theojp-libsfolder.
Download the IBM DB2 JDBC driver and place it in the ojp-libs directory:
# Option 1: Copy from your DB2 installation
# Common locations:
# Linux: /opt/ibm/db2/V11.5/java/db2jcc4.jar
# Windows: C:\Program Files\IBM\SQLLIB\java\db2jcc4.jar
# Create ojp-libs directory if it doesn't exist
mkdir -p ojp-libs
# Copy the driver
cp /opt/ibm/db2/V11.5/java/db2jcc4.jar ./ojp-libs/
# Optional: Add license jar if needed
cp /opt/ibm/db2/V11.5/java/db2jcc_license_cu.jar ./ojp-libs/
# Option 2: Download from Maven Central
# You can download the DB2 JDBC driver from Maven Central:
# https://mvnrepository.com/artifact/com.ibm.db2/jcc
# For example, version 11.5.9.0:
wget -P ojp-libs https://repo1.maven.org/maven2/com/ibm/db2/jcc/11.5.9.0/jcc-11.5.9.0.jar
# Or using curl:
# curl -o ojp-libs/jcc-11.5.9.0.jar https://repo1.maven.org/maven2/com/ibm/db2/jcc/11.5.9.0/jcc-11.5.9.0.jar
# Verify the files are in place
ls -lh ojp-libs/db2jcc*.jarFor more details on driver setup, see the Database Drivers Configuration Guide.
In a separate terminal:
cd ojp
mvn verify -pl ojp-server -Prun-ojp-serverTo run only DB2 tests:
cd ojp-jdbc-driver
mvn test -DenableDb2TestsTo run DB2 tests alongside other databases:
cd ojp-jdbc-driver
mvn test -DenableDb2Tests -DenableOracleTests -DenableSqlServerTestsTo run specific DB2 test classes:
cd ojp-jdbc-driver
mvn test -Dtest=Db2* -DenableDb2Tests=truedb2_connections.csv- DB2-only connection configurationh2_postgres_mysql_mariadb_oracle_sqlserver_connections.csv- Multi-database configuration including DB2
- URL:
jdbc:ojp[localhost:1059]_db2://localhost:50000/defaultdb - User:
db2inst1 - Password:
testpassword - Database:
defaultdb
The DB2 connection string for OJP follows this format:
jdbc:ojp[localhost:1059]_db2://db2host:50000/database
Where:
localhost:1059- OJP server address and portdb2://localhost:50000- DB2 instancedatabase- Target database name
DB2 tests are skipped by default, use:
mvn testAlso can explicitly disable DB2 tests as in:
mvn test -DenableDb2Tests=falseIn DB2 JDBC driver, both LOBs and ResultSetMetaData become invalid once the cursor advances or the ResultSet is accessed from another thread. To handle this, OJP reads rows one at a time when LOBs are present instead of batching multiple rows and eagerly caches LOB data and metadata immediately upon row access to ensure consistency and prevent driver exceptions.