Presents your JAVA E-NEWSLETTER for December 12, 2002 <-------------------------------------------> SNOOP ON SQL STATEMENTS WITH P6LOG JDBC's PreparedStatement class is very powerful, but it can be a pain sometimes--especially when dealing with error messages. The prepared statement will handle the type conversion, so how will you know what formatting error occurred? The solution is to listen to the SQL statements as they are sent to your driver using P6Spy's P6Log. Installing P6Spy into a simple environment involves getting the Zip file from the Web site and then editing the spy.properties file to include the database driver you currently use. Next you put the spy.properties file and p6spy.jar in your classpath. Then you change the database code to point to "com.p6spy.engine.spy.P6SpyDriver" rather the name of your real driver. The database URL and all other code remains the same. When you run your code, a spy.log file will be created containing the SQL statements that were run by the system. For example: 1028592292236|57|0|statement|SELECT * FROM user where user=?| SELECT * FROM user where user='root' This is the output when a prepared statement is run to find out the details for the root user in MySQL. A spy.log file and some scripting can create a nice report of which statements are run most often and which arguments are most common. ----------------------------------------