Reputation: 1635
I am trying to access a DB2 instance via SSL port. I have the certificate that I need to access it. But I am not sure of the parameter that I need to add it to so that connection is successful.
Dataset<Row> data=session.read().jdbc("jdbc:db2://url:port/DBNAME"+":sslConnection=true"
, "db2inst1.JOB_STATUS", connectionProperties);
connectionProperties.put("driver", "com.ibm.db2.jcc.DB2Driver");
connectionProperties.put("url", "jdbc:db2://url:port/DBNAME");
connectionProperties.put("user", "db2inst1");
connectionProperties.put("password", "xxxxx");
The python code to connect to the same DB2 instance is this :
"DATABASE=DB_NAME;HOSTNAME=url;SSL=TRUE;PORT=port;PROTOCOL=TCPIP;UID=xxxx;PWD=xxxx;SSLServerCertificate=DB2Certificate.arm;;SECURITY=SSL"
I would want to provide the DB2Certificate.arm as a parameter to the jdbc url , similar to the python parameter of SSLServerCertificate . How can I do this ?
Upvotes: 0
Views: 5563
Reputation: 41
I can connect fine with sslConnection=true;sslCertLocation=...
but for some reason (come on, IBM!) you need a semicolon after each value.
This works:
jdbc:db2://192.168.1.69:50011/testdb:sslConnection=true;sslCertLocation=/tmp/db2.pem;
This does NOT work (the only difference is the missing final semicolon):
jdbc:db2://192.168.1.69:50011/testdb:sslConnection=true;sslCertLocation=/tmp/db2.pem
I get the exception:
com.ibm.db2.jcc.am.SqlSyntaxErrorException: [jcc][10165][10051][4.32.28] Invalid database URL syntax: jdbc:db2://192.168.1.69:50011/testdb:sslConnection=true;sslCertLocation=/tmp/db2.pem. ERRORCODE=-4461, SQLSTATE=42815
That's just silly... Anyway, there you go, put a semicolon at the end of each name=value;
Upvotes: 0
Reputation: 12314
Does the following URL work for you?
jdbc:db2://url:port/DBNAME:sslConnection=true;sslCertLocation=/full_path/DB2Certificate.arm;
Upvotes: 1
Reputation: 12267
Configuring your JRE/JVM to use SSL with Db2 for Linux/Unix/Windows is described here and also here.
The exact version of your jdbc driver can also influence what configuration options exist (db2jcc4.jar, db2jcc.jar ).
Notice that configuring JRE is a different activity from configuring CLI programs (such as Python).
Suggest you try to follow the docs first.
Upvotes: 1