Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003

    Unanswered: How to get the Query string from executeQuery()?


    I am implementing a wrapper for a specific JDBC driver and have the following question. In the executeQuery() method in PreparedStatement, I need to do some crazy stuff with the query before executing it. How do I get a hold of the actual String representing the query ? Obviously the Statement has the String somewhere, but I just cant figure out how to get a hold of it.

    This is what I need:

    MyPreparedStatement pstmt = con.prepareStmt(strSQL);
    ResultSet rs = pstmt.executeQuery();

    I need to get hold of strSQL inside MyPreparedStatement.executeQuery();


  2. #2
    Join Date
    Jan 2004
    If you are using a PreparedStatement object then you will not be able to access the SQL string because the PreparedStatement represents a precompiled SQL statement. There are no methods to access the string, even if the JDBC driver doesn't send the statement to the server for precompilation.

    The only way to manipulate the SQL statement is through the PreparedStatement setXXX() methods to bind the values of any parameters in the statement.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts