Introduction

You can connect to your JDBC data source data using Java using the high-performance JDBC-ODBC Bridge Driver. We'll walk you through the entire setup.

Let's not waste time and get started!

Prerequisites

Before we begin, make sure you meet the following prerequisite: Java Runtime Environment (JRE) or Java Development Kit (JDK) must be installed on your system.

If your JDBC Driver targets a different Java version (e.g., 11 / 17 / 21), install the corresponding or newer Java version.

If you already have a JRE installed, you can try using it too. However, if you experience any issues, we recommend using one of the distributions mentioned above (you can install an additional JRE next to the existing one; just don't forget to configure the default Java in the Windows Environment Variables).

Download your Java application JDBC driver

To connect to your Java application, you will have to download JDBC driver for it, which we will use in later steps. Let's perform these little steps right away:

  1. Visit your Java application website or MVN Repository.

  2. Select the appropriate JDBC driver version in Latest Versions section in MVN Repository:

    Select JDBC driver version in MVN Repository
  3. Download the JDBC driver, and save it locally, e.g. to D:\Drivers\JDBC\app-jdbc.jar.

    Download JDBC driver JAR file in MVN Repository
  4. Done! That was easy, wasn't it? Let's proceed to the next step.

Create data source in ZappySys Data Gateway

In this section we will create a data source for JDBC-ODBC Bridge in the Data Gateway. Let's follow these steps to accomplish that:

  1. Download and install ODBC PowerPack (if you haven't already).

  2. Search for gateway in the Windows Start Menu and open ZappySys Data Gateway Configuration:

    Open ZappySys Data Gateway Service Manager
  3. Go to the Users tab and follow these steps to add a Data Gateway user:

    • Click the Add button
    • In the Login field enter a username, e.g., john
    • Then enter a Password
    • Check the Is Administrator checkbox
    • Click OK to save
    Data Gateway - Add User
  4. Now we are ready to add a data source:

    • Click the Add button
    • Give the Data source a name (have it handy for later)
    • Then select Native - ZappySys JDBC Bridge Driver
    • Finally, click OK
    JdbcOdbcBridgeDSN
    ZappySys JDBC Bridge Driver
    Data Gateway - Add data source
  5. Now, we need to configure the JDBC connection in the new ODBC data source. Simply enter the Connection string, credentials, configure other settings, and then click Test Connection button to test the connection:

    JdbcOdbcBridgeDSN
    jdbc:exampleApp://app-service-host-name.com:1234
    com.provider.exampleApp.jdbc.AppDriver
    D:\Drivers\JDBC\app-jdbc.jar
    admin
    *************
    [{"Name":"AppParameter","Value":"12345"}]
    JDBC-ODBC Bridge driver data source settings

    Use these values when setting parameters:

    • Connection string: jdbc:exampleApp://app-service-host-name.com:1234
    • Driver class: com.provider.exampleApp.jdbc.AppDriver
    • JDBC driver file(s): D:\Drivers\JDBC\app-jdbc.jar
    • User name: admin
    • User password: *************
    • Connection parameters: [{"Name":"AppParameter","Value":"12345"}]

  6. You should see a message saying that connection test is successful:

    ODBC connection test is successful
  7. Otherwise, if you are getting an error, start by troubleshooting the JDBC connection with DBeaver in the section below:

    Jump to troubleshooter

  8. We are at the point where we can preview a SQL query. For more SQL query examples visit JDBC Bridge documentation:

    JdbcOdbcBridgeDSN
    SELECT * FROM orders
    JDBC ODBC Bridge data source preview
    SELECT * FROM orders
    You can also click on the <Select Table> dropdown and select a table from the list.

    The ZappySys JDBC Bridge Driver acts as a transparent intermediary, passing SQL queries directly to the JDBC driver, which then handles the query execution. This means the JDBC-ODBC Bridge Driver simply relays the SQL query without altering it.

    Some JDBC drivers don't support INSERT/UPDATE/DELETE statements, so you may get an error saying "action is not supported" or a similar one. Please, be aware, this is not the limitation of ZappySys JDBC Bridge Driver, but is a limitation of the specific JDBC driver you are using.

  9. Click OK to finish creating the data source.

  10. Once done, go to the Network Settings tab and Add a firewall rule for inbound traffic:

    Data Gateway - Add firewall rule for inbound connections
    • This will initially allow all inbound traffic.
    • Click Edit IP filters to restrict access to specific IP addresses or ranges.
  11. Crucial Step: After creating or modifying the data source, you must:

    • Click the Save button to persist your changes.
    • Hit Yes when prompted to restart the Data Gateway service.

    This ensures all changes are properly applied:

    ZappySys Data Gateway - Save Changes
    Skipping this step may cause the new settings to fail, preventing you from connecting to the data source.

Read data in Java from the DSN

  1. Java code to get the data:

    "jdbc:sqlserver://localhost:5000;databasename=JdbcOdbcBridgeDSN;user=john;password=test"
    Java code to Make ZappySys Driver Data Source Call

  2. When you run the code it will make the API call and read the data:
    Java code ZappySys Driver Data Source Results

  3. Here is Java program's code in text format:

    
    //Step-1: Install ZappySys ODBC PowerPack and Configure Data Gateway
    
    //Step-2:Assuming the Microsoft SQL Server JDBC Driver is in below folder
    //C:\Program Files\Microsoft Jdbc Driver 6.0 for SQL Server\sqljdbc_6.0\enu\auth\x64
    package padaone;
    
    import java.sql.*;
    
    public class zappy {
    
        public static void main(String[] args) {
    
            // Create a variable for the connection string.
            String connectionUrl = "jdbc:sqlserver://localhost:5000;databasename=JdbcOdbcBridgeDSN;user=test;password=test";
    
            // Declare the JDBC objects.
            Connection con = null;
            Statement stmt = null;
            ResultSet rs = null;
    
                try {
                    // Establish the connection.
                    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
                    con = DriverManager.getConnection(connectionUrl);
    
                    // Create and execute an SQL statement that returns some data.
                    String SQL = "SELECT Country , SUM(UnitPrice * Quantity) Total " 
                               + "FROM value " 
                               + "GROUP BY Country "
                               + "WITH (SRC='https://services.odata.org/V3/Northwind/Northwind.svc/Invoices?$format=json')";
                    stmt = con.createStatement();
                    rs = stmt.executeQuery(SQL);
    
                    // Iterate through the data in the result set and display it.
                    while (rs.next()) {
                        System.out.println(rs.getString(1) + " " + rs.getString(2));
                    }
                }
    
            // Handle any errors that may have occurred.
            catch (Exception e) {
                e.printStackTrace();
            } 
            
            finally {
                if (rs != null) try { rs.close(); } catch (Exception e) {}
                if (stmt != null) try { stmt.close(); } catch (Exception e) {}
                if (con != null) try { con.close(); } catch (Exception e) {}
            }
        }
    }

Troubleshooting

Validating JDBC connection in DBeaver

If you are experiencing JDBC connection issues, start by testing your JDBC driver in a JDBC client tool like DBeaver. If the JDBC connection fails in DBeaver, it naturally will not work in your ODBC data source either.

Create generic JDBC driver

  1. Download and install DBeaver Community Edition.

  2. Open DBeaver.

  3. Click Database in the top menu and select Driver Manager:

    Open Driver Manager in DBeaver
  4. Click the New button to start adding a custom JDBC driver:

    Start adding new JDBC driver in DBeaver
  5. Configure the connection settings by entering the Driver Name and Class Name (com.provider.exampleApp.jdbc.AppDriver):

    Configure JDBC driver connection settings
    com.provider.exampleApp.jdbc.AppDriver
  6. Go to the Libraries tab, click Add File, and select your JDBC-ODBC Bridge driver library file(s), e.g. D:\Drivers\JDBC\app-jdbc.jar:

    Add JAR library to JDBC driver
    Make sure to add all the required library dependencies.
  7. Your JDBC driver jar library is now added:

    JAR library added
    D:\Drivers\JDBC\app-jdbc.jar
  8. (Optional). If required by your JDBC driver, add additional properties by going to the Default properties tab, Right-clicking on the background, and selecting Add new property:

    Add new property
  9. Click on a value to modify it, then click OK to finish:

    Set property value

We are now ready to test the connection. Let's proceed!

Test connection

  1. Click the New Database Connection icon in the toolbar:

    Create new database connection in DBeaver
  2. Select your newly created JDBC driver from the list and click Next:

    Select custom JDBC driver
  3. Enter your JDBC URL (e.g. jdbc:exampleApp://app-service-host-name.com:1234), click Test Connection to verify it works, and then click Finish:

    Configure and test JDBC connection
    jdbc:exampleApp://app-service-host-name.com:1234
  4. Finally, expand the database and table list to check the connection status:

    Confirm connection success

There are two possible outcomes from the connection test:

SUCCESS
  • Reason:
    The JDBC driver works perfectly, meaning the issue lies within your ODBC data source configuration.
  • Action:
    Double-check your ODBC data source configuration and ensure it matches the settings that successfully connected in DBeaver.
FAILURE
  • Reason:
    There is likely an issue with the JDBC driver configuration or the connection details provided.
  • Action:
    Contact the ZappySys Support Team for assistance.

If you are still experiencing issues or need further help, please contact us:

Chat with an Expert

Frequent issues and solutions

Below are some useful community articles to help you troubleshoot and configure the ZappySys JDBC Bridge Driver:

Conclusion

In this guide, we demonstrated how to connect to JDBC-ODBC Bridge using Java and integrate your data — all without writing complex code. ZappySys JDBC Bridge Driver allows you to connect to any Java application that supports JDBC.

Ready to get started? Download ODBC PowerPack now or ping us via chat if you still need help: