JDBC Driver for DB2

Build 23.0.8839

Establishing a Connection

Creating a JDBC Data Source

You can create a JDBC data source to connect from your Java application. Creating a JDBC data source based on the CData JDBC Driver for DB2 consists of three basic steps:

  • Add the driver JAR file to the classpath. The JAR file is located in the lib subfolder of the installation directory. Note that the .lic file must be located in the same folder as the JAR file.
  • Provide the driver class. For example:
    cdata.jdbc.db2.DB2Driver
  • Provide the JDBC URL. For example:
    jdbc:db2:Server=10.0.1.2;Port=50000;User=admin;Password=admin;Database=test
    
    or
    
    jdbc:cdata:db2:Server=10.0.1.2;Port=50000;User=admin;Password=admin;Database=test

    The second format above can be used whenever there is a conflict in your application between drivers using the same URL format to ensure you are using the CData driver. The URL must start with either "jdbc:db2:" or "jdbc:cdata:db2:" and can include any of the connection properties in name-value pairs separated with semicolons.

Connecting to DB2

Set the following properties to connect:
  • Server: The name of the server running DB2.
  • Port: The port the DB2 server is listening on.
  • Database: The name of the DB2 database.

Authenticating to DB2

The driver supports authenticating directly to the DB2 with user credentials as well as authenticating using the API key of an application integrated with DB2, such as Watson Query.

DB2 User Credentials

Set AuthScheme to USRIDPWD. Provide the following credentials:

  • User: The username of a user with access to the database.
  • Password: The password of a user with access to the database.

IAM

The driver supports authenticating to the DB2 server using the API key of an application that connects to it, such as Watson Query.

Set AuthScheme to IBMIAMAuth. Provide the following credentials:

  • User: The IBMid or service ID tied to a user of the DB2 server.
  • Password: The API key associated with the application that requires access to the DB2 database.

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 23.0.8839