EasyManuals Logo

IBM DB2 User Manual

IBM DB2
585 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #78 background imageLoading...
Page #78 background image
Providing extended client information to the data source with
client info properties
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:
1. Create a Connection.
2. Call the java.sql.setClientInfo method to set any of the client info properties
that the database server supports.
3. Execute an SQL statement to cause the information to be sent to the database
server.
The following code performs the previous steps to pass a user name and a
workstation name to the DB2 server. The numbers to the right of selected
statements correspond to the previously-described 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();
}
}
}
Figure 20. Example of passing extended client information to a DB2 server
62 Application Programming Guide and Reference for Java

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the IBM DB2 and is the answer not in the manual?

IBM DB2 Specifications

General IconGeneral
DeveloperIBM
Initial Release1983
LicenseProprietary
Written inC, C++
CategoryDatabase Management System (RDBMS)
Operating SystemLinux, Windows
Programming LanguagesC, C++
Data ModelsRelational
EditionsCommunity, Standard, Advanced
Key Featureshigh availability, scalability