Connection URL examples
- Last Updated: August 23, 2024
- 3 minute read
- DataDirect Connectors
- JDBC
- Documentation
After setting the CLASSPATH, the connection information needs to be passed in the form of a connection URL. This section provides examples of connection strings configured to use common features and functionality. You can modify and/or combine these examples to create a connection string for your environment.
- Connection property names are case-insensitive. For example,
Passwordis the same aspassword. - For connection properties that support string values, use the following
escape sequence to specify values containing leading or trailing spaces and
curly brackets:
{value}. For example:User={hello }orPassword={{hello}}.
- User ID and password authentication
- User ID and password authentication with AES encryption
- Client authentication
- Kerberos authentication
- GSS plug-in authentication
- Connection failover
- Proxy server authentication
- TLS/SSL server encryption
- TLS/SSL client encryption
User ID and password authentication
This string includes the properties used to connect using user ID and password authentication.
- For Db2 for Linux, UNIX, and Windows; Db2 Hosted; and Db2 Warehouse on
Cloud:
jdbc:datadirect:db2://myserver:50000; DatabaseName=MyDB;User=jsmith;Password=secret; - For Db2 for i and Db2 for
z/OS:
jdbc:datadirect:db2://myserver:446; LocationName=MyLocation;User=test;Password=secret;
For more information on these properties and values, see User ID/password authentication.
User ID and password authentication with AES encryption
This string includes the properties used to connect using user ID and password authentication and encrypt data using AES encryption with random number generator for secure seeding.
- For Db2 for Linux, UNIX, and Windows; Db2 Hosted; and Db2 Warehouse on
Cloud:
jdbc:datadirect:db2://myserver:50000;DatabaseName=MyDB; AuthenticationMethod=encryptedUIDPasswordAES;RandomGenerator=random; SecureRandomAlgorithm=SHA1PRNG;User=jsmith;Password=secret; - For Db2 for i and Db2 for
z/OS:
jdbc:datadirect:db2://myserver2:446;LocationName=MyLocation; AuthenticationMethod=encryptedUIDPasswordAES;RandomGenerator=random; SecureRandomAlgorithm=SHA1PRNG;User=jsmith;Password=secret;
For more information on these properties and values, see Random number generator secure seeding.
Client authentication
This string includes the properties used to connect using client authentication.
- For Db2 for Linux, UNIX, and Windows; Db2 Hosted; and Db2 Warehouse on
Cloud:
jdbc:datadirect:db2://myserver:50000; DatabaseName=MyDB;AuthenticationMethod=client; - For Db2 for i and Db2 for
z/OS:
jdbc:datadirect:db2://myserver:446; LocationName=MyLocation;AuthenticationMethod=client;
For more information on these properties and values, see Client authentication.
Kerberos authentication
This string includes the properties used to connect using Kerberos authentication.
- For Db2 for Linux, UNIX, and Windows; Db2 Hosted; and Db2 Warehouse on
Cloud:
jdbc:datadirect:db2://myserver:50000; DatabaseName=MyDB;AuthenticationMethod=kerberos; - For Db2 for i and Db2 for
z/OS:
jdbc:datadirect:db2://myserver:446; LocationName=MyLocation;AuthenticationMethod=kerberos;
This authentication method requires knowledge of how to configure your Kerberos environment and supports Windows Active Directory Kerberos and MIT Kerberos. For more information, see Kerberos authentication.
GSS plug-in authentication
This string includes the properties used to connect using GSS plug-in authentication.
- For Db2 for Linux, UNIX, and Windows; Db2 Hosted; and Db2 Warehouse on
Cloud:
jdbc:datadirect:db2://myserver:50000; DatabaseName=MyDB;AuthenticationMethod=pluginSecurity; GSSPluginName=gssapi_name; - For Db2 for i and Db2 for
z/OS:
jdbc:datadirect:db2://myserver:446; LocationName=MyLocation;AuthenticationMethod=pluginSecurity; GSSPluginName=gssapi_name;
java.util.Properties properties = new java.util.Properties();
properties.put("GSSPluginObject", new DB2GSSPlugin());
Connection connection= DriverManager.getConnection(connectionUrl, properties);For more information on these properties and values, see GSS plug-in authentication.
Connection failover
This string includes the properties used to connect using connection failover.
- For Db2 for Linux, UNIX, and Windows; Db2 Hosted; and Db2 Warehouse on
Cloud:
jdbc:datadirect:db2://myserver1:50000;DatabaseName=MyDB; User=jsmith;Password=secret;AlternateServers=(myserver2:50000; myserver3:50000);ConnectionRetryCount=2;ConnectionRetryDelay=5; - For Db2 for i and Db2 for
z/OS:
jdbc:datadirect:db2://myserver1:446;LocationName=MyLocation; User=jsmith;Password=secret;AlternateServers=(myserver2:446; myserver3:446);ConnectionRetryCount=2;ConnectionRetryDelay=5;
For more information on these properties and values, see Failover.
Proxy server
This string includes the properties used to connect using connection failover.
- For Db2 for Linux, UNIX, and Windows; Db2 Hosted; and Db2 Warehouse on
Cloud:
jdbc:datadirect:db2://myserver:50000;DatabaseName=MyDB; ProxyHost=pserver;ProxyPort=1234;ProxyUser=jsmith; ProxyPassword=proxys3cr3t;User=jsmith@abc.com;Password=secret; - For Db2 for i and Db2 for
z/OS:
jdbc:datadirect:db2://myserver:446;LocationName=MyLocation; ProxyHost=pserver;ProxyPort=1234;ProxyUser=jsmith; ProxyPassword=proxys3cr3t;User=jsmith@abc.com;Password=secret;
For more information on these properties and values, see Proxy server.
TLS/SSL server encryption
This string includes the properties used for TLS/SSL server encryption with user ID/password authentication.
- For Db2 for Linux, UNIX, and Windows; Db2 Hosted; and Db2 Warehouse on
Cloud:
jdbc:datadirect:db2://myserver:50000;DatabaseName=MyDB; EncryptionMethod=ssl;TrustStore=TrustStorePath; TrustStorePassword=secrettruststore;User=jsmith; Password=secret; - For Db2 for i and Db2 for
z/OS:
jdbc:datadirect:db2://myserver:50000;LocationName=MyLocation; EncryptionMethod=ssl;TrustStore=TrustStorePath; TrustStorePassword=secrettruststore;User=jsmith; Password=secret;
For more information on these properties and values, see Configuring TLS/SSL encryption.
TLS/SSL client encryption
This string includes the properties used for TLS/SSL client encryption with user ID/password authentication.
- For Db2 for Linux, UNIX, and Windows; Db2 Hosted; and Db2 Warehouse on
Cloud:
jdbc:datadirect:db2://myserver:50000;DatabaseName=MyDB; EncryptionMethod=ssl;KeyStore=KeyStorePath; KeyStorePassword=secretkeystore;User=jsmith; Password=secret; - For Db2 for i and Db2 for
z/OS:
jdbc:datadirect:db2://myserver:50000;LocationName=MyLocation; EncryptionMethod=ssl;KeyStore=KeyStorePath; KeyStorePassword=secretkeystore;User=jsmith; Password=secret;
For more information on these properties and values, see Configuring TLS/SSL encryption.