A set of IBM® Data Server Driver for JDBC and SQLJ-only methods provide extra information about the client to the server. This information can be used for accounting, workload management, or debugging.
Extended client information is sent to the database server when the application performs an action that accesses the server, such as executing SQL.
In the IBM Data Server Driver for JDBC and SQLJ version 4.0 or later, the IBM Data Server Driver for JDBC and SQLJ-only methods are deprecated. You should use java.sql.Connection.setClientInfo instead.
The IBM Data Server Driver for JDBC and SQLJ-only methods are listed in the following table.
Method | Information provided |
---|---|
setDB2ClientAccountingInformation | Accounting information |
setDB2ClientApplicationInformation | Name of the application that is working with a connection |
setDB2ClientDebugInfo | The CLIENT DEBUGINFO connection attribute for the Unified debugger |
setDB2ClientProgramId | A caller-specified string that helps the caller identify which program is associated with a particular SQL statement. setDB2ClientProgramId does not apply to DB2® for Linux, UNIX, and Windows data servers. |
setDB2ClientUser | User name for a connection |
setDB2ClientWorkstation | Client workstation name for a connection |
To set the extended client information, follow these steps:
public class ClientInfoTest {
public static void main(String[] args) {
String url = "jdbc:db2://sysmvs1.stl.ibm.com:5021/san_jose";
try {
Class.forName("com.ibm.db2.jcc.DB2Driver");
String user = "db2adm";
String password = "db2adm";
Connection conn = DriverManager.getConnection(url, 1
user, password);
if (conn instanceof DB2Connection) {
DB2Connection db2conn = (DB2Connection) conn; 2
db2conn.setDB2ClientUser("Michael L Thompson"); 3
db2conn.setDB2ClientWorkstation("sjwkstn1");
// Execute SQL to force extended client information to be sent
// to the server
conn.prepareStatement("SELECT * FROM SYSIBM.SYSDUMMY1"
+ "WHERE 0 = 1").executeQuery(); 4
}
} catch (Throwable e) {
e.printStackTrace();
}
}
}