简体   繁体   中英

Can I connect to IBM Db2 Event Store using the standard Db2 Client JAR?

I am trying to connect to an IBM Db2 Event Store cluster from a Java application that is already connecting to a Db2 instance. Can I have the same application connect to the Event Store instance using the same Jar ?

I've found my answer in this github repository containing samples for Db2 Event Store remote applications.

It seems pretty straight forward, like any regular connection to a Db2 instance, but in the case of Db2 Event Store Enterprise Edition, it is configured with SSL out of the box, so there are a few more parameters that are required for the connection to be successful. From that document, these are the steps that I extracted:

  • First we will need to know the external IP and port to be used for JDBC connections. To do this, login to the master node 1 of the installed Db2 Event Store cluster and run: kubectl get sac -n dsx Get the EXTERNAL-IP column value for the eventstore-tenant-engine-svc service, and the port number is 18729 from the exported ports (PORT(S) column) that corresponds to the JDBC port.
  • Download the SSL keystore and password through the REST API using the instructions documented in the IBM Knowledge Center for Db2 Event Store. This is necessary because Db2 Event Store is configured with SSL with a default keystore out of the box (this may change if you configure your own keystore after installation). This is the link to the documentation for REST
  • Then to establish the connection from your application, in the DriverManager.getConnection invocation, use the IP, Port, the location for the keystore, and the password, jdbc:db2://<Your Db2 Event Store Cluster VIP>:18729/EVENTDB:sslConnection=true;sslTrustStoreLocation=<path to clientkeystore downloaded from cluster>;sslKeyStoreLocation=<path to clientkeystore downloaded from cluster>;sslKeyStorePassword=<password for clientkeystore retrieved from cluster>;sslTrustStorePassword=<password for clientkeystore retrieved from cluster>;securityMechanism=15;pluginName=IBMIAMAuth; . ** Note that this is the JDBC connection URL. The database name EVENTDB is the default database that is created by Db2 Event Store at install time.
  • If you do not already have it, download the Db2 JDBC client driver from the IBM Data Server Client Packages page under the IBM Support website and store it in your CLASSPATH
           // Establish connection with ssl and user credentials
           conn =
           DriverManager.getConnection(
                    "jdbc:db2://" + IP + ":18729/EVENTDB:" +
                    "sslConnection=true;" +
                    "sslTrustStoreLocation="+ KEYDB_PATH + ";" +
                    "sslKeyStoreLocation="+ KEYDB_PATH + ";" +
                    "sslKeyStorePassword="+ KEYDB_PASSWORD + ";" +
                    "sslTrustStorePassword="+ KEYDB_PASSWORD + ";" +
                    "securityMechanism=15;" +
                    "pluginName=IBMIAMAuth;", 
                    USERNAME, PASSWORD);

An alternative to downloading the Keystore and its password is to just download the certificate, also through the REST API using the instructions documented in the IBM Knowledge Center for Db2 Event Store. This is the link to the documentation for REST

  • Then to establish the connection from your application, in the DriverManager.getConnection invocation, use the IP, Port, the certificate file location, jdbc:db2://<Your Db2 Event Store Cluster VIP>:18729/EVENTDB:sslConnection=true;sslCertLocation=<path to certificate downloaded from cluster>;securityMechanism=15;pluginName=IBMIAMAuth; . ** Note that this is the JDBC connection URL. The database name EVENTDB is the default database that is created by Db2 Event Store at install time.
           // Establish connection with ssl and user credentials
           conn =
           DriverManager.getConnection(
                    "jdbc:db2://" + IP + ":18729/EVENTDB:" +
                    "sslConnection=true;" +
                    "sslCertLocation="+ CERT_PATH + ";" +
                    "securityMechanism=15;" +
                    "pluginName=IBMIAMAuth;", 
                    USERNAME, PASSWORD);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM