DB2 Version 9.7 for Linux, UNIX, and Windows

DB2PooledConnection class

The com.ibm.db2.jcc.DB2PooledConnection class provides methods that an application server can use to switch users on a preexisting trusted connection.

Trusted connections are supported for:
  • IBM® Data Server Driver for JDBC and SQLJ type 4 connectivity to:
    • DB2® for Linux, UNIX, and Windows Version 9.5 or later
    • DB2 for z/OS® Version 9.1 or later
    • IBM Informix® Version 11.70 or later
  • IBM Data Server Driver for JDBC and SQLJ type 2 connectivity on DB2 for z/OS Version 9.1 or later

DB2PooledConnection methods

The following methods are defined only for the IBM Data Server Driver for JDBC and SQLJ.

getConnection (untrusted or trusted reuse without reauthentication)
Format:
public DB2Connection getConnection()
  throws java.sql.SQLException

This method is for dirty reuse of a connection. This means that the connection state is not reset when the object is reused from the pool. Special register settings and property settings remain in effect unless they are overridden by passed properties. Global temporary tables are not deleted. Properties that are not specified are not re-initialized. All JDBC standard transient properties, such as the isolation level, autocommit mode, and read-only mode are reset to their JDBC defaults. Certain properties, such as user, password, databaseName, serverName, portNumber, planName, and pkList remain unchanged.

getDB2Connection (trusted reuse)
Formats:
public DB2Connection getDB2Connection(byte[] cookie,
  String user,
  String password,
  String userRegistry,
  byte[] userSecToken,
  String originalUser,
  java.util.Properties properties)
  throws java.sql.SQLException
public Connection getDB2Connection(byte[] cookie,
  org.ietf.GSSCredential gssCredential,
  String usernameRegistry,
  byte[] userSecToken,
  String originalUser,
  java.util.Properties properties)
  throws java.sql.SQLException

Switches the user that is associated with a trusted connection without authentication.

The second form of getDB2Connection is supported only for IBM Data Server Driver for JDBC and SQLJ type 4 connectivity.

Parameter descriptions:
cookie
A unique cookie that the JDBC driver generates for the Connection instance. The cookie is known only to the application server and the underlying JDBC driver that established the initial trusted connection. The application server passes the cookie that was created by the driver when the pooled connection instance was created. The JDBC driver checks that the supplied cookie matches the cookie of the underlying trusted physical connection to ensure that the request originated from the application server that established the trusted physical connection. If the cookies match, the connection can become available, with different properties, for immediate use by a new user .
user
The client identity that is used by the data source to establish the authorization ID for the database server. If the user was not authenticated by the application server, the application server must pass a user identity that represents an unauthenticated user.
password
The password for user.
gssCredential
If the data source uses Kerberos security, specifies a delegated credential that is passed from another principal.
userNameRegistry
A name that identifies a mapping service that maps a workstation user ID to a z/OS RACF® ID. An example of a mapping service is the Integrated Security Services Enterprise Identity Mapping (EIM). The mapping service is defined by a plugin. Valid values for userNameRegistry are defined by the plugin providers. If userNameRegistry is null, the connection does not use a mapping service.
userSecToken
The client's security tokens. This value is traced as part of DB2 for z/OS accounting data. The content of userSecToken is described by the application server and is referred to by the data source as an application server security token.
originalUser
The client identity that sends the original request to the application server. originalUser is included in DB2 for z/OS accounting data as the original user ID that was used by the application server.
properties
Properties for the reused connection. These properties override any properties that are already defined on the DB2PooledConnection instance.
getDB2Connection (untrusted reuse with reauthentication)
Formats:
public DB2Connection getDB2Connection(
  String user,
  String password,
  java.util.Properties properties)
  throws java.sql.SQLException
public DB2Connection getDB2Connection(org.ietf.jgss.GSSCredential gssCredential,
  java.util.Properties properties)
  throws java.sql.SQLException

Switches the user that is associated with a untrusted connection, with authentication.

The first form getDB2Connection provides a user ID and password. The second form of getDB2Connection is for connections that use Kerberos security.

Parameter descriptions:
user
The user ID that is used by the data source to establish the authorization ID for the database server.
password
The password for user.
properties
Properties for the reused connection. These properties override any properties that are already defined on the DB2PooledConnection instance.
getDB2Connection (untrusted or trusted reuse without reauthentication)
Formats:
public java.sql.Connection getDB2Connection(
  java.util.Properties properties)
  throws java.sql.SQLException

Reuses an untrusted connection, without reauthentication.

This method is for dirty reuse of a connection. This means that the connection state is not reset when the object is reused from the pool. Special register settings and property settings remain in effect unless they are overridden by passed properties. Global temporary tables are not deleted. Properties that are not specified are not re-initialized. All JDBC standard transient properties, such as the isolation level, autocommit mode, and read-only mode are reset to their JDBC defaults. Certain properties, such as user, password, databaseName, serverName, portNumber, planName, and pkList remain unchanged.

Parameter descriptions:
properties
Properties for the reused connection. These properties override any properties that are already defined on the DB2PooledConnection instance.