Getting Started with the CData JDBC Driver for DB2

Complete guide to installing, licensing, and connecting with the CData JDBC Driver for DB2.


This guide walks you through everything you need to get started with the CData JDBC driver for DB2. You'll learn how to install and license the driver, configure your first connection, and explore next steps for working with DB2 data in your Java applications.

Installation & Licensing

Installing the Driver

  1. Download the JDBC driver installer from the CData site.
  2. Run the installer and follow the installation wizard.
  3. The driver will be installed to the following location: C:\Program Files\CData\CData JDBC Driver for DB2 20xx\lib\
  4. The JAR file will be named: cdata.jdbc.db2.jar

Once installed, you can add the JAR file to your Java project's classpath using your IDE or build tool.


Activating Your License

You should have received your license key via email from the CData Orders Team. The alphanumeric license key should take the following format:

XXXX-XXXX-XXXX-XXXX-XXXX
Windows

On Windows, the primary licensing method is via license file. When you install the JDBC driver, a license file is automatically created and stored with the driver installation. The driver will automatically detect and use this license file when the JAR is loaded in your application.

If you need to manually activate or update your license:

  1. Locate the license file in your installation directory.
  2. Update the license file with your license key.
  3. The driver will automatically use the updated license on the next connection.
macOS/Linux

Navigate to the JAR's installation directory and in the lib folder run the following command: java -jar cdata.jdbc.db2.jar --license

Follow the prompts to enter your license key. This will create a license file in the installation directory that the driver will use for licensing validation.

For detailed license file configuration instructions, refer to the Licensing section under the Getting Started sub-page in the help documentation.


Common Licensing Questions

Can I use my license on multiple machines?
Yes, depending on your subscription tier. Check your order confirmation or contact your account representative for details. If you are unsure of who your account representative is, contact [email protected].

I lost my license key. How do I retrieve it?
Email [email protected] with your order number, and we'll resend your license key.

Can I transfer my license to a different machine?
Yes. When transferring the license to a different machine, you will need to submit a License Transfer Request on our site linked below:

https://www.cdata.com/lic/transfer/

After the License Transfer Request is submitted and successfully processed, an activation will be added to your Product Key and you will be able to activate the full license on the other machine. Once this process is finished, the license on the previous machine will be invalid.

When should I use RTK instead of the license file?
Use RTK when deploying to environments where the machine/node ID changes dynamically, such as containers, cloud instances, or when distributing your application to multiple machines.

For additional licensing questions, contact [email protected]. Viewing and upgrading your license can now be done through our self-service portal at portal.cdata.com.


Connection Configuration

Once your driver is installed and licensed, you're ready to configure a connection to DB2. JDBC connections are established using a connection URL (also called a connection string).

Understanding JDBC Connection URLs

JDBC connection URLs for CData drivers follow this pattern:

jdbc:db2:Server=10.0.1.2;Port=50000;User=admin;Password=admin;Database=test;

Building Your Connection URL

Recommended: Use the Built-in Connection String Designer

The JDBC driver includes a connection string designer tool that helps you build the correct JDBC URL with all required connection properties.

To launch the Connection String Designer:
  1. Navigate to the driver installation directory: C:\Program Files\CData\CData JDBC Driver for DB2 20xx\lib\
  2. Double-click the JAR file: cdata.jdbc.db2.jar
    OR
    Run from the command line: java -jar cdata.jdbc.db2.jar
  3. The Connection String Designer will open.
  4. Fill in your connection properties in the provided fields.
  5. Click Test Connection to verify your settings.
  6. Copy the generated JDBC URL from the designer.

The Connection String Designer ensures correct syntax and shows all available connection properties for DB2.

Driver Class Name

When configuring the JDBC driver in IDEs (such as IntelliJ IDEA, Eclipse, or DBeaver) or other tools, you will need to specify the driver class name:

cdata.jdbc.db2.DB2Driver

Configuring Connection Properties

The specific connection properties required depend on your data source.

Set the following properties to connect to DB2:

  • Server: Set this to the name of the server running DB2.
  • Port: Set this to the port the DB2 server is listening on.
  • Database: Set this to the name of the DB2 database.
  • User: Set this to the username of a user allowed to access the database.
  • Password: Set this to the password of a user allowed to access the database.

You will also need to install the corresponding DB2 driver:

  • Windows: Install the IBM Data Server Provider for .NET.

    On Windows, installing the IBM Data Server Provider is sufficient, as the installation registers it in the machine.config.

  • Java: Install the IBM Data Server Driver for JDBC.

    In the Java version, place the IBM Data Server Driver JAR in the www\WEB-INF\lib\ folder for this application.

For complete information on all available connection properties for DB2, refer to the Establishing a Connection section in the help documentation.


Testing Your Connection

You can test your connection in several ways:

In the Connection String Designer

Click the Test Connection button after entering your properties. A successful test confirms your credentials and connection settings are correct.

In Your Application

If the application requires you to move the driver JAR to a specific location, do so now and ensure the JAR is included in your application's classpath. Also, ensure that the .lic file is also moved to the same location for licensing validation purposes.

Note: Many JDBC Connected tools, like DBeaver, do not actually send a live request to the provider when using their Test Connection functionality. It only does a surface test, which essentially just checks that the JAR file functions at a base level. When using a JDBC connected tool, the ConnectOnOpen property should be set to True to ensure a valid Test Connection.

If you are working with the JDBC driver in your IDE, you can execute a simple query to verify the connection:

import java.sql.Connection; 
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

String url = "jdbc:db2:Server=10.0.1.2;Port=50000;User=admin;Password=admin;Database=test;
Connection conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM Orders LIMIT 1");

if (rs.next()) {
    System.out.println("Connection successful!");
}


If you encounter connection errors:

  1. Verify that your connection properties are correct using the Connection String Designer.
  2. Check that the driver JAR is in your application's classpath.
  3. Review the error message for specific guidance.
  4. Contact [email protected] with the error details for troubleshooting assistance.

Common Connection Issues

Driver Not Found / ClassNotFoundException

Solution: Ensure the JDBC driver JAR (cdata.jdbc.db2.jar) is properly added to your project's classpath. The configuration method varies by IDE and build tool. Refer to your development environment's documentation or contact [email protected] for assistance.

Authentication Errors

Solution: Verify that your credentials are correct and current. Use the Connection String Designer to test your credentials before adding them to your application. For specific authentication requirements for DB2, consult the Establishing a Connection section in the help documentation.

Network Connectivity Issues

Solution: Ensure that your firewall allows outbound connections on the required ports. Contact [email protected] for specific port and firewall requirements for your data source.

Invalid Connection String Format

Solution: Use the Connection String Designer to generate a properly formatted JDBC URL. The designer ensures correct syntax and property names.

For additional troubleshooting, contact [email protected] with your specific error message.


What's Next

Now that you have installed, licensed, and configured the driver, here are some scenarios you can use to explore our JDBC Drivers:

JDBC ClientArticle Title
Aqua Data StudioConnect to DB2 in Aqua Data Studio
AWS DatabricksProcess & Analyze DB2 Data in Databricks (AWS)
BirstBuild Visualizations of DB2 in Birst
BIRTDesign BIRT Reports on DB2
FineReportFeed DB2 into FineReport
JasperServerCreate DB2 Reports on JasperReports Server
Jaspersoft BI SuiteConnect to DB2 in Jaspersoft Studio
JReport DesignerIntegrate with DB2 in JReport Designer
KNIMEEnable the DB2 JDBC Driver in KNIME
MicroStrategyUse the CData JDBC Driver for DB2 in MicroStrategy
Microstrategy DesktopUse the CData JDBC Driver for DB2 in MicroStrategy Desktop
Microstrategy WebUse the CData JDBC Driver for DB2 in MicroStrategy Web
OBIEEDB2 Reporting in OBIEE with the DB2 JDBC Driver
Pentaho Report DesignerIntegrate DB2 in the Pentaho Report Designer
RAnalyze DB2 in R (JDBC)
RapidMinerConnect to DB2 in RapidMiner
SAP Business ObjectsCreate an SAP BusinessObjects Universe on the CData JDBC Driver for DB2
SAP Crystal ReportsPublish Reports with DB2 in Crystal Reports (JDBC)
SisenseVisualize Live DB2 in Sisense
Spago BIConnect to DB2 in SpagoBI
TIBCO Spotfire ServerOperational Reporting on DB2 from Spotfire Server
Apache SolrImport DB2 Data into Apache Solr
Coginiti ProAccess Live DB2 Data in Coginiti Pro
DataGripQeury DB2 Data in DataGrip
DB ArtisanManage DB2 in DBArtisan as a JDBC Source
DBeaverConnect to DB2 in DBeaver
DbVisualizerConnect to DB2 in DBVisualizer
Informatica Enterprise Data CatalogAdd DB2 to Informatica Enterprise Data Catalog
QuerySurgeValidate DB2 Data with QuerySurge
RazorSQLConnect to DB2 in RazorSQL
SQuirreLConnect to DB2 in Squirrel SQL Client
AWS LambdaAccess Live DB2 Data in AWS Lambda
Apache SparkWork with DB2 in Apache Spark Using SQL
ColdFusionQuery DB2 in ColdFusion Using JDBC
Filemaker Pro (on Mac)Bidirectional Access to DB2 from FileMaker Pro (on Mac)
HibernateObject-Relational Mapping (ORM) with DB2 Entities in Java
IntelliJConnect to DB2 in IntelliJ
JBossConnect to DB2 from a Connection Pool in JBoss
JDBICreate a Data Access Object for DB2 using JDBI
JetBrains RubyMineIntegrate DB2 with JetBrains RubyMine
JRubyConnect to DB2 in JRuby
MendixBuild DB2-Connected Apps in Mendix (JDBC)
RunMyProcess DSECConnect to DB2 in DigitalSuite Studio through RunMyProcess DSEC
ServoyBuild DB2-Connected Apps in Servoy
Spring BootAccess Live DB2 Data in Spring Boot Apps
TomcatConfigure the CData JDBC Driver for DB2 in a Connection Pool in Tomcat
WebLogicConnect to DB2 from a Connection Pool in WebLogic
APOS Live Data GatewayBuild Semantic Layer Views for DB2 (JDBC)
DenodoCreate A Data Source for DB2 in Denodo Platform
DremioConnect to DB2 as an External Source in Dremio
PostgreSQL FDWA PostgreSQL Interface for DB2
Apache AirflowBridge DB2 Connectivity with Apache Airflow
Apache CamelIntegrate with DB2 using Apache Camel
Apache NiFiBridge DB2 Connectivity with Apache NiFi
Apache NiFi Batch OperationsPerform Batch Operations with DB2 Data in Apache NiFi
CloverDXConnect to DB2 in CloverDX (formerly CloverETL)
ETL ValidatorHow to Work with DB2 in ETL Validator
Google Data FusionBuild DB2-Connected ETL Processes in Google Data Fusion
HULFT IntegrateConnect to DB2 in HULFT Integrate
Informatica CloudIntegrate DB2 in Your Informatica Cloud Instance
Informatica PowerCenterCreate Informatica Mappings From/To a JDBC Data Source for DB2
Jaspersoft ETLConnect to DB2 in Jaspersoft Studio
Oracle Data IntegratorETL DB2 in Oracle Data Integrator
Pentaho Data IntegrationIntegrate DB2 in Pentaho Data Integration
SnapLogicIntegrate DB2 with External Services using SnapLogic (JDBC)
TalendConnect to DB2 and Transfer Data in Talend
MuleSoft AnypointAccess DB2 in Anypoint Using SQL

Get Support

If you need assistance at any point:


FAQs


Installation & Licensing

  • Where is the JDBC driver installed?
    The default installation directories are the following:
    Windows: C:\Program Files\CData\CData JDBC Driver for DB2 \lib
    Mac: /Application/CData JDBC Driver for DB2 /lib
    Linux: /home//CData/CData JDBC Driver for DB2 /lib
  • How do I retrieve my license key?
    Your license key is sent via email when you purchase. If you need it resent, contact [email protected] with your order number.
  • Can I use my license across multiple applications?
    Yes. The license file works across all your Java applications on your machine that use the driver.
  • When should I use RTK (Runtime Key)?
    Use RTK when deploying to environments where machine/node IDs change dynamically: containers (Docker/Kubernetes), cloud instances, or when distributing your application across multiple machines. If you require an RTK, reach out to your Account Representative.

Connecting

  • How do I build a JDBC connection URL?
    Use the built-in Connection String Designer tool. Double-click the driver JAR or run java -jar cdata.jdbc.db2.jar to launch the designer. It will help you build a properly formatted connection URL.
  • What is the driver class name?
    The driver class follows this pattern: cdata.jdbc.db2.DB2Driver
    You'll need this when configuring the driver in IDEs like IntelliJ IDEA, Eclipse, or DBeaver.
  • What connection properties does DB2 require?
    Refer to the Establishing a Connection section in the help documentation for complete details on required and optional connection properties for DB2. The Connection String Designer also shows all available properties.
  • How do I connect to multiple DB2 accounts?
    Create separate connection URLs with different authentication credentials for each account. You can manage multiple connections in your application.
  • How do I store credentials securely?
    Use environment variables, configuration files, or secrets management systems (like AWS Secrets Manager or Azure Key Vault). Never hardcode credentials in your source code.

Usage & Development

  • Which SQL operations are supported?
    Refer to the SQL Compliance chapter in the help documentation for the complete list of supported SQL operations.
  • Can I use the driver in a multi-threaded application?
    Yes. Follow standard JDBC best practices for thread safety. Use connection pooling for concurrent access.
  • How do I add the driver to my IDE?
    Add the JAR file (cdata.jdbc.db2.jar) to your project's classpath. Refer to your IDE's documentation for adding external JARs. The driver class name is: cdata.jdbc.db2.DB2Driver

Performance & Troubleshooting

  • Why are my queries slow?
    Check the following:
    • Use connection pooling.
    • Add filters (WHERE clauses) to reduce result set size.
    • Contact [email protected] for query optimization assistance.
  • How do I enable logging for troubleshooting?
    Add logging properties to your connection string or configure logging in your application by setting the Logfile property to a valid file path and the Verbosity property to a desired logging level (we typically recommmend setting Verbosity=3 to capture http requests and responses). Refer to the Advanced Features section of the help documentation for logging configuration details. Contact [email protected] for troubleshooting assistance.
  • What firewall ports need to be open?
    Port requirements vary by data source. Most cloud applications use HTTPS (port 443). Refer to the Advanced Features section of the help documentation for Firewall & Proxy configuration if needed. Contact [email protected] for specific firewall requirements for DB2.
  • How do I deploy the driver in Docker?
    Include the driver JAR in your Docker image and use RTK (Runtime Key) for licensing in your connection string. This handles dynamic container node IDs.
  • I'm getting ClassNotFoundException. How do I fix it?
    This means the driver JAR is not in your classpath. Verify the JAR file location and ensure it's added to your project's classpath in your IDE or build configuration.

General

  • Where can I find the help documentation?
    The help documentation is installed with the driver in the installation directory and is also available on the CData website.
  • How often is the driver updated?
    CData releases major version updates for our drivers annually. Check your account portal or contact [email protected] for the latest version.
  • Do you offer code examples for specific use cases?
    Yes. The help documentation includes numerous code examples. Contact [email protected] if you need examples for a specific scenario.

For questions not covered in this FAQ, contact [email protected].

Ready to get started?

Download a free trial of the IBM DB2 Driver to get started:

 Download Now

Learn more:

IBM DB2 Icon IBM DB2 JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with IBM DB2.