0

I have a java app that does a lot of writes to a mysql database. It's important that data not be lost so if the mysql connection is disrupted and someone shuts down the app, the data in the application's queue is lost.

I need to find a way to properly write the queries to a file when the app shuts down, so that next time it starts up I can load the unsaved data and try to process it.

The issue is that I can't find a way to view the final sql statement from the preparedStatement system, and the data for the queries isn't easy to write to a file because it all comes from a variety of objects.

Is there a way to grab the complete query so that I can write it to a file if the db connection is gone?

I assume not - is there an alternative other than just building the sql myself?

helion3
  • 34,737
  • 15
  • 57
  • 100

1 Answers1

0

You can do

preparedStatement.toString() 

if you're using the JDBC MySQL driver.

Alternatively, you can use Log4JDBC

Anujan
  • 928
  • 1
  • 9
  • 20