PreparedStatement and prewiev SQL query

Discussion in 'Java' started by tomas, Sep 16, 2006.

  1. tomas

    tomas Guest

    I have question it is posible to see SQL query when I use PreparedStatement
    and print SQL query to console ?
     
    tomas, Sep 16, 2006
    #1
    1. Advertising

  2. tomas wrote:
    > I have question it is posible to see SQL query when I use
    > PreparedStatement and print SQL query to console ?


    Yes. But only with the ? not with the data.

    Arne
     
    =?UTF-8?B?QXJuZSBWYWpow7hq?=, Sep 16, 2006
    #2
    1. Advertising

  3. tomas

    Tom Cole Guest

    tomas wrote:
    > I have question it is posible to see SQL query when I use PreparedStatement
    > and print SQL query to console ?


    Not all drivers support this, and it's not part of the standard, but
    many will allow you to call toString() (after you've set your
    parameters) and see the SQL Statement.

    Connector/J does this, the PostgreSQL driver does this as well. I
    haven't tried jTDS or the JDBC/ODBC Bridge...

    You may also find this useful:

    http://www.javaworld.com/javaworld/jw-01-2002/jw-0125-overpower.html
     
    Tom Cole, Sep 16, 2006
    #3
  4. tomas

    Bomber Guest

    Thy this software, it intercepts the database call and prints out both
    the original sql and the sql with the substitution values into a log
    file.

    http://www.p6spy.com/
     
    Bomber, Sep 16, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Manoj S. P.
    Replies:
    2
    Views:
    4,416
    Manoj S. P.
    Jul 2, 2003
  2. Ken Philips
    Replies:
    4
    Views:
    49,017
    venkat.sadasivam
    Nov 5, 2008
  3. JY
    Replies:
    11
    Views:
    25,126
    Andrea Desole
    Feb 24, 2006
  4. ddog
    Replies:
    1
    Views:
    2,091
    Thomas Kellerer
    Feb 7, 2007
  5. Christian

    SQL PreparedStatement

    Christian, Dec 1, 2007, in forum: Java
    Replies:
    10
    Views:
    1,061
    Christian
    Dec 1, 2007
Loading...

Share This Page