com.ibm.db2.jcc.DB2SimpleDataSource db2ds =
new com.ibm.db2.jcc.DB2SimpleDataSource();
// Create DB2SimpleDataSource object
db2ds.setDriverType(4); // Set the driver type
db2ds.setDatabaseName("san_jose"); // Set the location
db2ds.setServerName("mvs1.sj.ibm.com");
// Set the server name
db2ds.setPortNumber(5021); // Set the port number
db2ds.setUser("db2adm"); // Set the user ID
db2ds.setSecurityMechanism(
com.ibm.db2.jcc.DB2BaseDataSource.USER_ONLY_SECURITY);
// Set security mechanism to
// user ID only
Related tasks
“Connecting to a data source using the DataSource interface” on page 15
“Connecting to a data source using the DriverManager interface with the IBM
Data Server Driver for JDBC and SQLJ” on page 11
“Creating and deploying DataSource objects” on page 19
Related reference
“Properties for the IBM Data Server Driver for JDBC and SQLJ” on page 201
Encrypted password, user ID, or user ID and password security under
the IBM Data Server Driver for JDBC and SQLJ
IBM Data Server Driver for JDBC and SQLJ supports encrypted password security,
encrypted user ID security, or encrypted user ID and encrypted password security
for accessing data sources.
The IBM Data Server Driver for JDBC and SQLJ supports 56-bit DES (weak)
encryption or 256-bit AES (strong) encryption. AES encryption is available with
IBM Data Server Driver for JDBC and SQLJ type 4 connectivity only. You set the
encryptionAlgorithm driver property to choose between 56-bit DES encryption
(encryptionAlgorithm value of 1) and 256-bit AES encryption (encryptionAlgorithm
value of 2). 256-bit AES encryption is used for a connection only if the database
server supports it and is configured to use it.
If you use encrypted password security, encrypted user ID security, or encrypted
user ID and encrypted password security from a DB2 for z/OS client, the Java
Cryptography Extension, IBMJCE for z/OS needs to be enabled on the client. The
Java Cryptography Extension is part of the IBM Developer Kit for z/OS, Java 2
Technology Edition. For information on how to enable IBMJCE, go to this URL on
the Web: http://www.ibm.com/servers/eserver/zseries/software/java/j5jce.html
For AES encryption, you need to get the unrestricted policy file for JCE. It is
available at the following URL: https://www14.software.ibm.com/webapp/iwm/
web/preLogin.do?source=jcesdk
Connections to DB2 for i V6R1 or later servers can use encrypted password
security or encrypted user ID and encrypted password security. For encrypted
password security or encrypted user ID and encrypted password security, the IBM
Java Cryptography Extension (ibmjceprovidere.jar) must be installed on your client.
The IBM JCE is part of the IBM SDK for Java, Version 1.4.2 or later.
You can also use encrypted security-sensitive data in addition to encrypted user ID
security or encrypted user ID and encrypted password security. You specify
encryption of security-sensitive data through the
Chapter 10. Security under the IBM Data Server Driver for JDBC and SQLJ 451
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|