User ID/password authentication
- Last Updated: May 9, 2024
- 2 minute read
- DataDirect Connectors
- JDBC
- Documentation
To configure the driver to use user ID/password authentication:
- Set the AuthenticationMethod connection property to one of the following valid user ID/
password values. The default is
clearText.clearText: The driver sends the user ID and password in clear text to the Db2 server for authentication.encryptedPassword: The driver sends a clear text user ID and an encrypted password to the Db2 server for authentication.encryptedPasswordAES: The driver sends a clear text user ID and an AES-encrypted password to the Db2 server for authentication.encryptedUIDPassword: The driver sends an encrypted user ID and password to the Db2 server for authentication.encryptedUIDPasswordAES: The driver sends an AES-encrypted user ID and password to the Db2 server for authentication.
Note: If you enable AES encryption by specifyingencryptedPasswordAESorencryptedUIDPasswordAES, you can configure random number generator secure seeding. If you want to configure secure seeding, complete your configuration of user id/password authentication by proceeding to "Random number generator secure seeding".Note: For more information on the user ID/password values, see "AuthenticationMethod". - 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 Password property to specify the password.
- 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.
- Set the User property to specify the user name that is used to connect to the database.
The following examples show the connection information required to connect to a Db2 for Linux, UNIX, and Windows database using user ID/password authentication.
Connection URL
Connection conn = DriverManager.getConnection
("jdbc:datadirect:db2://myserver:50000;DatabaseName=payroll;
User=test;Password=secret);
Data Source
Db2DataSource mds = new Db2DataSource();
mds.setDescription("My Db2 Data Source");
mds.setServerName("myserver");
mds.setPortNumber("50000");
mds.setDatabaseName("payroll");
mds.setUser("jsmith");
mds.setPassword("secret");
Note: The User and Password properties are not required to be stored in the
connection string. They can also be passed separately by the application.