[ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13086074#comment-13086074 ]
Siddharth Srivastava edited comment on DERBY-3676 at 8/17/11 1:12 AM: ---------------------------------------------------------------------- I too think toString() would be a more intuitive way. As I don' t think an explicit cast would be preferred by the users and hence wouldn't serve the purpose of the method. Moreover, as far as output format is concerned, following is what I would like to propose(Need reviews on this): For a statement as follows: PreparedStatement ps = conn.prepareStatement("INSERT INTO demo(ID,dBlob) VALUES(?,?)"); ps.setInt(1,1); ps.setBlob(1,is,BYTES.length); System.out.println(ps.toString()), currently outputs:ace4c0a3-0131-d540-4992-0000030d5ec8 New Proposed format: (based on logStatementText) CacheId:ace4c0a3-0131-d540-4992-0000030d5ec8::INSERT INTO Orders1(ID,dBlob) VALUES(?,?)::parameter #1: 1::parameter #2: BLOB(org.apache.derby.iapi.types.RawToBinaryFormatStream@5c2a1ed) For client PreparedStatement, cacheid can be set as null. was (Author: siddharthsrivastava): I too think toString() would be a more intuitive way. As I don' t think an explicit cast would be preferred by the users and hence wouldn't serve the purpose of the method. Moreover, as far as output format is concerned, following is what I would like to propose(Need reviews on this): For a statement as follows: PreparedStatement ps = conn.prepareStatement("INSERT INTO demo(ID,dBlob) VALUES(?,?)"); ps.setInt(1,1); ps.setBlob(1,is,BYTES.length); System.out.println(ps.toString()), currently outputs:ace4c0a3-0131-d540-4992-0000030d5ec8 New Proposed format: (based on logStatementText) CacheId:6c44409f-0131-d546-4475-0000030d5ec8::INSERT INTO Orders1(ID,dBlob) VALUES(?,?)::parameter #1: 1::parameter #2: BLOB(org.apache.derby.iapi.types.RawToBinaryFormatStream@5c2a1ed) For client PreparedStatement, cacheid can be set as null. > 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