IBM DB2 Manual page 79

Table of Contents

Advertisement

|
|
|
Table 11. Client info property values for DB2 Database for Linux, UNIX, and Windows and for DB2 for i
NAME
ApplicationName
ClientAccountingInformation
ClientHostname
ClientUser
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,
user, password);
conn.setClientInfo("ClientUser", "Michael L Thompson"); 2
conn.setClientInfo("ClientWorkstation, "sjwkstn1");
// Execute SQL to force extended client information to be sent
// to the server
conn.prepareStatement("SELECT * FROM SYSIBM.SYSDUMMY1"
+ "WHERE 0 = 1").executeQuery();
} catch (Throwable e) {
e.printStackTrace();
}
}
}
Figure 21. Example of passing extended client information to a DB2 server
Client info properties support by the IBM Data Server Driver for
JDBC and SQLJ
JDBC 4.0 includes client info properties, which contain information about a
connection to a data source. The DatabaseMetaData.getClientInfoProperties
method returns a list of client info properties that the IBM Data Server Driver for
JDBC and SQLJ supports.
When you call DatabaseMetaData.getClientInfoProperties, a result set is returned
that contains the following columns:
v NAME
v MAX_LEN
v DEFAULT_VALUE
v DESCRIPTION
The following table lists the client info property values that the IBM Data Server
Driver for JDBC and SQLJ returns for DB2 Database for Linux, UNIX, and
Windows and for DB2 for i.
MAX_LEN
DEFAULT_VALUE
255
Empty string
255
Empty string
255
The value that is set by
DB2Connection.setDB2ClientWorkstation. If
the value is not set, the default is the host
name of the local host.
255
Empty string
1
3
DESCRIPTION
The name of the application
that is currently using the
connection.
The value of the accounting
string from the client
information that is specified for
the connection.
The host name of the computer
on which the application that is
using the connection is running.
The name of the user on whose
behalf the application that is
using the connection is running.
Chapter 3. JDBC application programming
63

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents