1 Reply Latest reply on Sep 12, 2003 7:53 AM by rndgatewaynet

    PreparedStatement final actual SQL retrieval

    rndgatewaynet

      Is there a way to grab the actual SQL submitted to the DB somewhere around executeUpdate() ?

      I use Jboss Connection Pool and from what i've seen jboss wraps
      Postgresql's org.postgresql.jdbc3.Jdbc3Connection and org.postgresql.jdbc3Jdbc3PreparedStatement
      to org.jboss.resource.adapter.jdbc.local.LocalConnection and org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement.

      This way i just cant cast my PreparedStatement to
      org.postgresql.jdbc3Jdbc3PreparedStatement which has a convinient
      toString() method.

      Is there something equivalent for org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement??

      Anyone else had this need???

      There is always the standard way of creating a new wraper class
      that implements PreparedStatement, but since its already implemented
      in postgresql i hate to reimplement it.

      I am using the postgresql 7.3.4 jdbc driver, and running jboss 3.0.3.

        • 1. Re: PreparedStatement final actual SQL retrieval
          rndgatewaynet

          I found it!!

          PreparedStatement st = con.prepareStatement("insert into bar....");
          st.setInt(1,667);
          ......

          org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement jst = (org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement) st;
          org.postgresql.jdbc3.Jdbc3PreparedStatement pst = (org.postgresql.jdbc3.Jdbc3PreparedStatement) jst.getUnderlyingStatement();
          System.out.println(pst.toString());