sql - how to get the prepared statement query after binding -


i using prepared statement this

preparedstatement pstmt = getconnection().preparestatement(insert_query);         pstmt.setint(1,userdetails.getusersid());  log.debug("sql inserting child transactions " + pstmt.tostring()); 

i want log exact sql statement after binding log file thing not working. logging sqlserverpreparedstatement:7. searched on internet did not satisfactory answer. appreciated.

you can try enable jdbc internal logging setting printwriter on drivermanager. log4j2 provides io streams module can include output in normal log file. sample code:

printwriter logger = iobuilder.forlogger(drivermanager.class)         .setlevel(level.debug)         .buildprintwriter(); drivermanager.setlogwriter(logger); 

in addition, individual jdbc drivers provide proprietary logging mechanisms, enabled system property. need consult documentation specific driver details.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -