I'm looking to connect to a DB2 Warehouse on Cloud (DB2 WoC) Server using JDBC and IBMid/Password, provided IAM is enabled on the database instance. It is enabled on my Db2 WoC server. Here's the piece of code I'm trying to connect (This method is described here):
import com.ibm.db2.jcc.DB2SimpleDataSource
val dataSource: DB2SimpleDataSource = new DB2SimpleDataSource()
dataSource.setDriverType(4)
dataSource.setDatabaseName("BLUDB")
dataSource.setServerName("<server url>")
dataSource.setPortNumber(50001)
dataSource.setSslConnection(true)
dataSource.setSecurityMechanism(com.ibm.db2.jcc.DB2BaseDataSource.PLUGIN_SECURITY)
dataSource.setPluginName("IBMIAMauth")
val conn = dataSource.getConnection("<ibmid>", "<password>")
While trying to connect using this way, I get an error Connection authorization failure occurred. Reason: Invalid GSSAPI server credential. ERRORCODE=-4214, SQLSTATE=28000. Searching for this error on the internet led me to nowhere. Why is this happening? (My server URL is correct).
EDIT: I'm using db2jcc4.jar driver version 4.26.14 and I'm running this code on my local system trying to connect to the server url.
Not really an answer but this is too big for a comment.
You can troubleshoot connectivity problems without CLPPlus, as the driver itself contains an embedded test program that you can invoke like so:
Note the reference to the server certificate.
The above works on both the JDBC 3.0 driver
db2jcc.jarwhich is now depreciated, and the JDBC 4.0 driverdb2jcc4.jar