opticyclic
opticyclic

Reputation: 8136

Get Bind Variables In Oracle JDBC Logging

I am trying to debug my Java application that queries an Oracle database.

I have started my application with

-Doracle.jdbc.Trace=true  -Djava.util.logging.config.file=c:/tmp/oracledebug.properties  

Containing

handlers = java.util.logging.FileHandler
java.util.logging.FileHandler.pattern = c:/tmp/jdbc.log
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
oracle.jdbc.driver.level = CONFIG

However, it outputs the SQL with question marks.

Is it possible to log the values of the bind variables?

Upvotes: 0

Views: 1638

Answers (1)

jmehrens
jmehrens

Reputation: 11065

According to the documentation:

FINE Logs the entry and exit to every public method providing a detailed trace of JDBC operations. It produces a fairly high volume of log messages.

Set the system property -Djava.util.logging.SimpleFormatter.format="%1$tc %2$s %3$s%n%4$s: %5$s%6$s%n" to include the logger name in your output file.

When I set the oracle.jdbc.driver=FINE using the above SimpleFormatter pattern I see output like:

Wed Nov 02 08:43:06 CDT 2016 oracle.jdbc.driver.OraclePreparedStatement setString oracle.jdbc.driver
FINE: XXXXXXXX Public Enter: 1, "some input string"

Everything after Public Enter: are the arguments to PreparedStatement.setString(int, String).

Upvotes: 2

Related Questions