[
https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13080626#comment-13080626
]
Tiago R. Espinha commented on DERBY-3676:
-----------------------------------------
Hi Siddharth,
This patch, if I recall correctly and from a quick visual inspection, is
actually using the override approach, where toString() is redefined to output
the query with the replaced values. You would have to rename the toString()
method in the DerbyPreparedStatement interface to getFullSQLText() and in all
classes that implement it.
Then you simply have to do:
String sqlText ((DerbyPreparedStatement) ps).getFullSQLText();
You have a normal PreparedStatement, that you cast to a DerbyPreparedStatement
in order to access its getFullSQLText() method.
> Make the toString() method of Derby PreparedStatements print out SQL text
> with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-3676
> URL: https://issues.apache.org/jira/browse/DERBY-3676
> Project: Derby
> Issue Type: Improvement
> Components: JDBC
> Reporter: Rick Hillegas
> Assignee: Siddharth Srivastava
> Attachments: humanstringprepared.txt, humanstringprepared.txt,
> humanstringprepared.txt, humanstringprepared.txt, humanstringprepared.txt,
> humanstringprepared.txt, humanstringprepared.txt, ick.txt, ick.txt,
> prepared.diff, statementCacheVTI.sql
>
>
> This topic came up in the following email thread on the user list:
> http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811
> Here's what the thread requests:
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira