Is there any way to print PreparedStatement with binding data ? This will help me to debug a runtime exception I'm facing.
Presently, I'm using datasource and JNDI name configured in JBOSS server to establish database connection. I can not change the database driver configured in the server.
In my code , I do the following ..
ps = con.prepareStatement(<update-sql query>)
param1=//get data from list
param2 =///get data from list
System.out.println(ps.toString()) ---> This prints org.jboss.resource.adapter.jdbc.jdk6.WrappedPreparedStatementJDK6@1f1640f
I'm getting an Exception :
java.sql.BatchUpdateException: Cannot add or update a child row: a foreign key constraint fails .
The exception is quite understandable . And so, I'd like to reproduce the query with the binding data to troubleshoot further to find out query with values failed to update.