0

I am using preparedStatement.executeBatch() and addBatch() in the code and would like to inspect the query that is generated when executeBatch is finally called. I have used ojdbc_g.jar but couldn't see the batched query in the logs. Is there a way to see how the driver combines the queries and sends it across.

The logging.properties is :

.level=SEVERE oracle.jdbc.level=FINEST oracle.sql.level=FINEST oracle.jdbc.handlers=java.util.logging.ConsoleHandler,java.util.logging.FileHandler java.util.logging.ConsoleHandler.level=FINEST java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter

java.util.logging.FileHandler.level=FINEST java.util.logging.FileHandler.pattern=jdbc.log java.util.logging.FileHandler.count=1 java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter

user2599052
  • 1,056
  • 3
  • 12
  • 27
  • *"would like to inspect the query that is generated"* Why? You already know the statement. It's the string you gave in the call to `conn.prepareStatement(sql)`, and the values are as you gave in the calls to `stmt.setXxx()`. The driver doesn't change the SQL much, other than maybe replacing `?` with e.g. `:param1`, that's it. – Andreas Oct 12 '20 at 14:20
  • No, the batched queries look different – user2599052 Oct 12 '20 at 14:33
  • How do you know unless you've already logged them? And if you have, why are you asking how to log them? --- But sure, it might be different, e.g. the JDBC driver might have wrapped the SQL statement with a stored procedure, so it can be compiled just once, and the executes that procedure once for every `addBatch()` call you made. But the actual SQL is what the string given to `prepareStatement(sql)` was, the wrapping in a stored procedure is merely to improve execution performance, it doesn't effectively change the statement. – Andreas Oct 12 '20 at 14:38

0 Answers0