4 Replies Latest reply on Oct 11, 2012 4:46 AM by prabhun

    Logging PreparedStatement details

    prabhun

      Hi,

       

      Our application uses MySQL with JBoss EAP 6.0.

      We used to print the PreparedStatement query details in the log using the below approach

       

      logger.debug( " Query details " + preparedStatement.toString() ); -- [after it is set with all parameters]

       

      However after implementing connection pooling in JBoss we are getting a Wrapper statement

      and it just prints a object instance detail instead of query details like below

       

       

      Standalone configuration for Datasource is

       

      <datasource jta="false" jndi-name="java:jboss/datasources/testDS" pool-name="TestDataSource" enabled="true" use-ccm="false" >

               <connection-url>jdbc:mysql://localhost/test</connection-url>

                 <driver-class>com.mysql.jdbc.Driver</driver-class>

      <datasource-class>org.apache.commons.dbcp.BasicDataSource</datasource-class>

      ===========================================================

       

      The WrappedPreparedStatement has a getUnderlyingStatement() function to get the PreparedStatement, however for that

      we need to use JBoss specific Wrapper Classes, which will couple our application to a specific server implementation.

       

      What is the other way we get print the details of the PreparedStatemnt after it is set with all the parameters?

       

      Thanks