skip to main content
DataDirect tools : Connection Pool Manager : How connection pooling works : Using Reauthentication
  

Try DataDirect Drivers Now
Using Reauthentication
Typically, you can configure a connection pool to provide scalability for connections. In addition, to help minimize the number of connections required in a connection pool, you can switch the user associated with a connection to another user, a process known as reauthentication.
For example, suppose you are using Kerberos authentication to authenticate users using their operating system user name and password. To reduce the number of connections that must be created and managed, you can use reauthentication to switch the user associated with a connection to multiple users. For example, suppose your connection pool contains a connection, Conn, which was established by the user ALLUSERS. That connection can service multiple users (User A, B, and C) by switching the user associated with the connection Conn to User A, B, and C.
Not all databases support reauthentication. For databases that do, the user performing the switch must have been granted specific database permissions.
The following table shows the support for reauthentication and lists the required database permissions. Refer to your database documentation for information about granting permissions.
Table 10. Support for Reauthentication
Driver
Database
Database Permissions
Oracle
Oracle8i R2 and higher 1
CONNECT THROUGH
SQL Server
Microsoft SQL Server 2005 and higher 2, 3
IMPERSONATE

1 Oracle refers to reauthentication as proxy authentication.

2 Microsoft SQL Server refers to reauthentication as impersonation.

3 Reauthentication is not supported for SQL Server Azure, Analytics Data Warehouse, or Analytics Platform System (Parallel Data Warehouse).

Note: Before performing reauthentication, applications must ensure that any statements or result sets created as one user are closed before switching the connection to another user.
To perform reauthentication on a connection explicitly, call the setCurrentUser() method in the ExtConnection interface located in the com.ddtek.jdbc.extensions package. For example, the following code switches the user on the connection from the user that created the connection (TEST) to a new user (SMITH). In addition, it sets options that switch the current schema and current database path to the schema and database path of the new user.
import com.ddtek.jdbc.extensions.*
// Get Database Connection
Connection con = DriverManager.getConnection(
   "jdbc:datadirect:sqlserver://server1:1433;DatabaseName=jdbc", "TEST", "secret");
ExtConnection extCon = (ExtConnection)con
Properties props = new Properties();

props.put("CURRENT_SCHEMA", "SCHEMA");
props.put("CURRENT_PATH", "PATH");
ExtCon.setCurrentUser("SMITH", props);
...
See the appropriate driver chapters for information on supported options for each driver.
If you are using the DataDirect Connection Pool Manager for connection pooling, you can enable reauthentication in the Pool Manager. See "Using Reauthentication with the Pool Manager" for details.