The IBM® Data Server Driver for JDBC and SQLJ version 4.0 supports JDBC 4.0 client info properties, which you can use to 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.
The application can also use the Connection.getClientInfo method to retrieve client information from the database server, or execute the DatabaseMetaData.getClientInfoProperties method to determine which client information the driver supports.
The JDBC 4.0 client info properties should be used instead IBM Data Server Driver for JDBC and SQLJ-only methods, which are deprecated.
To set client info properties, 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);
conn.setClientInfo("ClientUser", "Michael L Thompson"); 2
conn.setClientInfo("ClientHostname", "sjwkstn1");
// Execute SQL to force extended client information to be sent
// to the server
conn.prepareStatement("SELECT * FROM SYSIBM.SYSDUMMY1"
+ "WHERE 0 = 1").executeQuery(); 3
} catch (Throwable e) {
e.printStackTrace();
}
}
}