Using DatabaseMetaData extensions to identify the Db2 Connect version and the IBM Data Server Driver for JDBC and SQLJ version

The DB2DatabaseMetaData.getDriverDB2ConnectLevel method identifies the version of Db2 Connect and the IBM Data Server Driver for JDBC and SQLJ version that an application is using for a connection to a data server.

About this task

Use the DB2DatabaseMetaData.getDriverDB2ConnectLevel method to identify the Db2 Connect version and the IBM Data Server Driver for JDBC and SQLJ version that an application is using for a connection to a data server.

Procedure

To invoke DB2DatabaseMetaData.getDriverDB2ConnectLevel method, you need to perform these basic steps:

  1. Create a DatabaseMetaData object by invoking the getMetaData method on the connection, and casting the DatabaseMetaData object to a DB2DatabaseMetaData object.
  2. Invoke the DB2DatabaseMetaData.getDriverDB2ConnectLevel method to get information about the Db2 Connect and IBM Data Server Driver for JDBC and SQLJ versions.

Example

The following code demonstrates how to use the DB2DatabaseMetaData.getDriverDB2ConnectLevel method to determine the Db2 Connect and IBM Data Server Driver for JDBC and SQLJ versions.

Connection con;
com.ibm.db2.jcc.DB2DatabaseMetaData dbmd;
String versionDetails;

dbmd = (DB2DatabaseMetaData) con.getMetaData();      // Create the DB2DatabaseMetaData object
versionDetails = dbmd.getDriverDB2ConnectLevel();    // Check the version of DB2Connect while 
                                                     // requesting IBM data server driver for 
                                                     // JDBC and SQLJ version driver version
System.out.println("DB2Connect version: " + versionDetails);