7.7.1 JDBC interface method traces
You can acquire a JDBC interface method trace as troubleshooting information when you call a method in the JDBC interface.
- Organization of this subsection
(1) Environment setup
(a) Connection with the DriverManager class
The following explains the environment setup procedure.
- To set up the environment:
-
-
Specify a valid log writer by executing the setLogWriter method of the DriverManager class.
-
Connect to the HADB server by executing the getConnection method of the DriverManager class. In the url or info argument of the getConnection method, specify that a JDBC interface method trace is to be acquired (specify methodtrace and tracenum).
For details about the specification of the url argument of the getConnection method, see (a) Values to be specified in the url argument (specifying the URL for the connection) in (2) Connecting to the HADB server with the getConnection method in 7.3.1 Using the getConnection method of the DriverManager class to connect to the HADB server.
For details about the specification of the info argument of the getConnection method, see (d) Values to be specified in the info argument (specifying the user properties) in (2) Connecting to the HADB server with the getConnection method in 7.3.1 Using the getConnection method of the DriverManager class to connect to the HADB server.
-
(b) Connection with the DataSource class
The following explains the environment setup procedure.
- To set up the environment:
-
-
Specify a valid log writer by executing the setLogWriter method of the DataSource or ConnectionPoolDataSource interface.
-
Specify that a JDBC interface method trace is to be acquired by executing the setInterfaceMethodTrace and setTraceNumber methods in the connection information setup and acquisition interface.
For details about the setLogWriter method of the DataSource interface, see 10.2.7 setLogWriter(PrintWriter out). For details about the setLogWriter method of the ConnectionPoolDataSource interface, see 10.3.7 setLogWriter(PrintWriter out).
For details about the setInterfaceMethodTrace method, see 10.5.14 setInterfaceMethodTrace(boolean flag). For details about the setTraceNumber method, see 10.5.18 setTraceNumber(int num).
-
(2) Rules for acquiring a JDBC interface method trace
This subsection describes the rules for acquiring a JDBC interface method trace.
-
Trace information is acquired when a method in the JDBC interface is called and when processing is returned from the method. However, trace information is not acquired for methods executed before a connection to the database is established. Trace information is also not acquired for the following methods:
Driver interface
-
acceptsURL(String url)
-
getMajorVersion()
-
getMinorVersion()
-
getPropertyInfo(String url, Properties info)
-
jdbcCompliant()
DataSource and ConnectionPoolDataSource interfaces
-
getLoginTimeout()
-
getLogWriter()
-
setLoginTimeout(int seconds)
-
setLogWriter(PrintWriter out)
Wrapper interfaces
-
isWrapperFor(Class<?> iface)
-
unwrap(Class<T> iface)
-
-
Trace information is stored for the specified number of entries and is output to the specified log writer at the following times:
-
When the Connection.close method is called (normal termination)
-
When an SQLException is thrown (error occurrence)
-
When a BatchUpdateException is thrown (error occurrence)
-
When an SQLClientInfoException is thrown (error occurrence)
-
When an UnsupportedOperationException is thrown (error occurrence)
-
-
If the number of trace information items exceeds the number of entries, the oldest stored trace information is discarded in chronological order and the newest trace information is retained.
-
A JDBC interface method trace uses a single-entry trace area for each Entry and each Return.
(3) Output example
This subsection shows an output example of a JDBC interface method trace. The item numbers in the explanation below correspond to the bracketed numbers in the figure.
Output example
Explanation
-
[Hitachi Advanced Data Binder JDBC Driver]
Name of the JDBC driver
-
[JDBC Interface Entry ] and [JDBC Interface Return]
[JDBC Interface Entry ]: Call to a JDBC method
[JDBC Interface Return]: Return from a JDBC method
-
[XXXXX.YYYYY]
YYYYY method of the XXXXX class
-
select * from pp
Argument in the JDBC method (for the password argument, an asterisk (*) is output, as in password=*)
-
com.hitachi.hadb.jdbc.Adb...
Value returned from the JDBC method