Db2

 View Only

 Java application struggles to connect to DB2

  • IBMChampion
Delphine Lanctin's profile image
Delphine Lanctin posted Tue January 28, 2025 11:53 AM

Hello,

We have a java application that struggles to connect to DB2. We are using icr.io/db2_community/db2:11.5.9.0 in a docker-compose set-up.

The java application has been recently migrated to Java 17, and in our testing, we noticed issues at start-up. The previous version of the java application, based on Java 11, didn't show issues connecting to the same version of DB2 ( 11.5.9.0).

The traces below are from the java application.

In some cases, it takes a long time to achieve connectivity, we see this:


2024-12-20T13:40:37,564  [Default Executor-thread-12] [] INFO util.ConnectionProxyHandler - Going to get connection..
2024-12-20T13:40:37,663  [Default Executor-thread-12] [] WARN util.ConnectionProxyHandler - CTJOT0857W The database is unavailable. Retry connecting to the database in 10 seconds. Retry number 19/20.
2024-12-20T13:40:47,664  [Default Executor-thread-12] [] INFO util.ConnectionProxyHandler - Going to get connection..
2024-12-20T13:40:47,739  [Default Executor-thread-12] [] WARN util.ConnectionProxyHandler - CTJOT0857W The database is unavailable. Retry connecting to the database in 10 seconds. Retry number 20/20.
2024-12-20T13:40:57,741  [Default Executor-thread-12] [] INFO util.ConnectionProxyHandler - Going to get connection..
2024-12-20T13:40:57,820  [Default Executor-thread-12] [] ERROR util.ConnectionProxyHandler - CTJOT0858E Fatal Error : Could not connect to the database.
com.ibm.db2.jcc.am.SqlException: DB2 SQL Error: SQLCODE=-1035, SQLSTATE=57019, SQLERRMC=null, DRIVER=4.25.29
        at com.ibm.db2.jcc.am.b6.a(b6.java:815) ~[db2jcc.jar:?]
        at com.ibm.db2.jcc.am.b6.a(b6.java:66) ~[db2jcc.jar:?]
        at com.ibm.db2.jcc.am.b6.a(b6.java:140) ~[db2jcc.jar:?]
        at com.ibm.db2.jcc.am.Connection.completeSqlca(Connection.java:5269) ~[db2jcc.jar:?]

This issue can be resolved by bringing the services down, and up again.

In other cases, we got connectivity faster but then get this error:


"2025-01-09T06:58:12,150  [Default Executor-thread-11] [] ERROR jdo.JdoDbInit - [JdoDbInit.E.9] DB schema was parially created. Please drop and re-create the schema
2025-01-09T06:58:12,152  [Default Executor-thread-11] [] ERROR jdo.JdoDbInit - [JdoDbInit.E.1] JdoDbInit.initDb() failed
com.ibm.cdb.topomgr.jdo.JdoInitException: [JdoDbInit.E.9] DB schema was parially created. Please drop and re-create the schema

We are wondering what could be causing those issues, and how to investigate what's happening from the DB2 side ?

This page https://www.ibm.com/support/pages/db2-jdbc-driver-versions-and-downloads shows that JDBC driver 4.25.29 corresponds to DB2 Level v11.1 M4 FP7. But I am not sure if it is relevant ?

Any help would be very appreciated.

Thanks,

Delphine.

Jan Nelken's profile image
Jan Nelken IBM Champion

The IBM Data Server Driver for JDBC and SQLJ package includes two JDBC drivers:

    db2jcc.jar - This driver is based on the JDBC 3 specification (Minimum required Java version 4)
    db2jcc4.jar - This driver is based on the JDBC 4 or later specifications (Minimum required Java version 6)


The db2jcc.jar driver is now deprecated. After version 3.72, which is delivered with DB2 Version 11.1 for Linux, UNIX, and Windows Mod 1 Fix Pack 1, db2jcc.jar will include no new features. However, fixes will continue to be delivered.

Starting with 12.1 the minimum JRE version required to use the db2jcc4.jar is JRE 1.8.

Db2 V12.1 includes driver version 4.34.30
Db2 V11.5.9 includes driver version 4.33.31

See: https://www.ibm.com/support/pages/db2-jdbc-driver-versions-and-downloads