Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
185 views
Welcome To Ask or Share your Answers For Others

1 Answer

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...