Db2

 View Only
Expand all | Collapse all

Connection string for JDBC Driver connection to DB2 using SSL installed on zOS 2.4

  • 1.  Connection string for JDBC Driver connection to DB2 using SSL installed on zOS 2.4

    Posted Mon January 09, 2023 04:59 PM
    Forgive me if this is a trivial question. 

    I am a Solution Architect and my customer has following setup for DB2

    A1PLEx runs on two IBM Z14 3906 Model 746. The Operating System is z/OS V2.5. Prod is still on z/OS V2.4

    They want to connect to DB2, as detailed above, using SSL certificates. I did see that there are some good help on the internet but I am really confused with which driver to use.

    I am using https://jt400.sourceforge.net/doc/com/ibm/as400/access/doc-files/JDBCProperties.html

    So I figured out a connection string, but it is generating a NullPointerException


    Can anyone help me with building the correct connection string and the driver to use for above ?


    Abhishek
    ------------------------------
    Abhishek A.
    ------------------------------

    ------------------------------
    Abhishek Asthana
    ------------------------------

    #Db2


  • 2.  RE: Connection string for JDBC Driver connection to DB2 using SSL installed on zOS 2.4

    Posted Tue January 10, 2023 01:25 PM

    Below is what I set up as a test, I do not actually load the Db2 driver, I assume it is done by Java.  The SSL is handled by Java, not the Db2 driver.  I do have db2jcc4.jar and optionally the db2jcc_license_cisuz.jar files in the CLASSPATH.

    import java.sql.*;
    import java.math.*;
    import java.io.*;

    class dbConnectSSL
    {
    public static void main (String args[]) throws SQLException, IOException
    {
    int c;

    // Read connect string from file

    String wUser = new String();
    String wPassword = new String();
    String wURL = new String();


    wUser = "xxxxxxxx";
    wPassword = "xxxxxxxx";
    wURL="jdbc:db2://LPAR:PORT/SSID";

    System.setProperty("javax.net.ssl.trustStoreType", "Windows-ROOT");

    java.util.Properties properties = new java.util.Properties();
    properties.put("user", wUser);
    properties.put("password", wPassword);
    properties.put("sslConnection", "true");
    java.sql.Connection wConn = java.sql.DriverManager.getConnection(wURL, properties);
    System.out.println ("Connected");
    wConn.close();
    System.out.println ("Disconnected");
    }
    }



    ------------------------------
    Tommy Petersen
    ------------------------------



  • 3.  RE: Connection string for JDBC Driver connection to DB2 using SSL installed on zOS 2.4

    Posted Tue January 10, 2023 04:22 PM
    Hi Tom, 

    Thank you for sending the code example. That really helped to understand the role of SSL during the connection building. 
    db2jcc4.jar is the driver I am also using. 

    And I am also using cacerts certificate. I am using a 3rd party application to connect (Java based) and there I am passing the connection string, username, password and other parameters.


    But I am constantly getting error

    Error during JDBC database connection: com.ibm.db2.jcc.am.SqlSyntaxErrorException: [jcc][10165][10036][4.32.28] Invalid database URL syntax: jdbc:db2://data.sys.devtest.env:6764/DBSYSTSEM;sslJdk13Certificate=/opt/dev/dev-dys-server/jre/lib/security/cacerts. ERRORCODE=-4461, SQLSTATE=42815

    Would you be able to build a connection string including the parameters based your program logic ?

    I will try running your program in dev.

    Thanks, 
    Abhishek A.



    ------------------------------
    Abhishek Asthana
    ------------------------------