JDBC API

Debug Trace

The driver is able to display debug traces for each JDBC statement called. This can be done using the system property 'ldbc.trace'.

Setting Meaning
off (default) Debug traces are switched off.
on Each JDBC method call is displayed on System.out, excluding ResultSet and PreparedStatement.setXXX calls. Parameters for the method calls are listed as well. SQLExceptions are listed. SQL statements are listed (the original statement, as well as the vendor specific SQL statement after the conversion).
detailed In addition to the 'on' setting, all ResultSet and PreparedStatement calls are listed. The result for each call is listed as well.

Logging to file

By default, the log stream is System.out, however a file can be specified:

ldbc.trace=<setting>,<filename>

The log stream is appended to this file. The file is created if it does not yet exist

How to set the debug trace option

The debug trace can be from the command prompt or in the JDBC url, using [ldbc.trace=...]

Examples for the command line:

java -Dldbc.trace=detail com.acme.App
java -Dldbc.trace=on,log.txt com.acme.App

Example database URLs:

jdbc:ldbc:jdbc:hsqldb:sample[ldbc.trace=on,test.txt]
jdbc:ldbc:jdbc:hsqldb:sample[ldbc.trace=detailed]

JDBC API implementation status

Most JDBC API methods are implemented, however there are still some parts missing.

The following classes are fully implemented:

Connection
DatabaseMetaData
Statement
PreparedStatement
ResultSet
ResultSetMetaData

Not yet implemented are:

CallableStatement
- All methods that are not part of PreparedStatement

Proposed Solution for Stored Procedures

Stored Procedures are very different across databases. Using native stored procedures is not a solution. The proposed solution is: The callable statement calls a client side Java method. The SQL Statement:

CALL ADD_CUSTOMER('Jon','Wayne','Cowboy')

Results in to the Java code:

Object obj=Class.forName("ADD_CUSTOMER").newInstance();
StoredProcedure proc=(StoredProcedure)obj;
proc.setConnection(conn);
proc.setParameter(1,"Jon");
proc.setParameter(2,"Wayne");
proc.setParameter(3,"Cowboy");
proc.executeUpdate();

A more advanced solution would be to store the bytecode of the class ADD_CUSTOMER in the database, and map procedure names to specific Java methods.

Direct access to underlying (database specific) JDBC objects

It is possible that an application need to access the vendor specific JDBC driver objects directly, for example for testing, or if a feature is not yet implemented in LDBC. For such cases, the method getVendorObject is implemented in Connection, Statement, PreparedStatement, ResultSet, ResultSetMetaData and DatabaseMetaData. Of course, this method should only be used if the problem can not be solved using the regular LDBC objects.