When client authentication is enabled (AuthenticationMethod=client), the driver uses the user ID of the user logged onto the system on which the driver is running when establishing a connection. The Db2 database server relies on the client to authenticate the user and does not provide additional authentication. The driver ignores any values specified by the User and Password properties.

To configure the driver to use client authentication:
  • Set the AuthenticationMethod connection property to client.
  • Set the DatabaseName property to specify the name of the database to which you want to connect. Valid only on Db2 for Linux, UNIX, and Windows; Db2 Hosted; and Db2 Warehouse on Cloud.
  • Set the LocationName property to specify the name of the Db2 location that you want to access. Valid only on Db2 for z/OS and Db2 for i.
  • Set the PortNumber property to specify the TCP port of the primary database server that is listening for connections to the database.
  • Set the ServerName property to specify either the IP address in IPv4 or IPv6 format, or the server name (if your network supports named servers) of the primary database server.

The following examples show the connection information required to connect to a Db2 for Linux, UNIX, and Windows database using client authentication.

Connection URL

Connection conn = DriverManager.getConnection 
("jdbc:datadirect:db2://myserver:50000;DatabaseName=payroll
  AuthenticationMethod=client);

Data Source

Db2DataSource mds = new Db2DataSource();
mds.setDescription("My Db2 Data Source");
mds.setServerName("myserver");
mds.setPortNumber("50000");
mds.setDatabaseName("payroll");
mds.setAuthenticationMethod("client");