You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by wbecker <wb...@gmail.com> on 2008/05/15 13:09:35 UTC

PreparedStatement.toString() - nice formatting

Is there a way to get a PreparedStatement to tell you what it is going to
give as a query to the db?

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. Is there a way to get a similar result with
Derby? All I seem to get is a string of gibberish, eg:
:54b48415-0119-ec3b-91d2-000001bca0c8"

Cheers,
Will
-- 
View this message in context: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-tp17250811p17250811.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Re: PreparedStatement.toString() - nice formatting

Posted by Bryan Pendleton <bp...@amberpoint.com>.
> I wrote a fix for this, but seeing the comments at
> https://issues.apache.org/jira/browse/DERBY-3676 I am not sure its a good
> idea.

Please feel free to attach the patch proposal to the JIRA issue anyway,
even if you think it may not be perfect. It may be just the thing
to help somebody else, or somebody else may have a look at it and
make a follow-on suggestion.

thanks,

bryan

Re: PreparedStatement.toString() - nice formatting

Posted by Rick Hillegas <Ri...@Sun.COM>.
Thanks for pushing this forward, Will. I have added another suggestion 
to DERBY-3676, an approach which could leverage what you've built 
already. Let's see if the community can improve this or surface more 
problems. Would the suggested approach satisfy your needs?

Regards,
-Rick

wbecker wrote:
> I wrote a fix for this, but seeing the comments at
> https://issues.apache.org/jira/browse/DERBY-3676 I am not sure its a good
> idea.
>
>
> Rick Hillegas-2 wrote:
>   
>> Hi Will,
>>
>> Thanks for bringing this up. I have logged DERBY-3676 to track this 
>> request. At first blush this looks like a straightforward project for a 
>> newcomer. If you want to implement this yourself, I would be happy to 
>> coach you through the code.
>>
>> Regards,
>> -Rick
>>
>> wbecker wrote:
>>     
>>> Is there a way to get a PreparedStatement to tell you what it is going to
>>> give as a query to the db?
>>>
>>> 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. Is there a way to get a similar result
>>> with
>>> Derby? All I seem to get is a string of gibberish, eg:
>>> :54b48415-0119-ec3b-91d2-000001bca0c8"
>>>
>>> Cheers,
>>> Will
>>>   
>>>       
>>
>>     
>
>   


Re: PreparedStatement.toString() - nice formatting

Posted by wbecker <wb...@gmail.com>.
I wrote a fix for this, but seeing the comments at
https://issues.apache.org/jira/browse/DERBY-3676 I am not sure its a good
idea.


Rick Hillegas-2 wrote:
> 
> Hi Will,
> 
> Thanks for bringing this up. I have logged DERBY-3676 to track this 
> request. At first blush this looks like a straightforward project for a 
> newcomer. If you want to implement this yourself, I would be happy to 
> coach you through the code.
> 
> Regards,
> -Rick
> 
> wbecker wrote:
>> Is there a way to get a PreparedStatement to tell you what it is going to
>> give as a query to the db?
>>
>> 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. Is there a way to get a similar result
>> with
>> Derby? All I seem to get is a string of gibberish, eg:
>> :54b48415-0119-ec3b-91d2-000001bca0c8"
>>
>> Cheers,
>> Will
>>   
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-tp17250811p17272201.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Re: PreparedStatement.toString() - nice formatting

Posted by wbecker <wb...@gmail.com>.
Hi,

I have half coded this anyway, so I might as well. I'll check out the code
and see how hard it is to write up a patch.

Cheers,
Will


Rick Hillegas-2 wrote:
> 
> Hi Will,
> 
> Thanks for bringing this up. I have logged DERBY-3676 to track this 
> request. At first blush this looks like a straightforward project for a 
> newcomer. If you want to implement this yourself, I would be happy to 
> coach you through the code.
> 
> Regards,
> -Rick
> 
> wbecker wrote:
>> Is there a way to get a PreparedStatement to tell you what it is going to
>> give as a query to the db?
>>
>> 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. Is there a way to get a similar result
>> with
>> Derby? All I seem to get is a string of gibberish, eg:
>> :54b48415-0119-ec3b-91d2-000001bca0c8"
>>
>> Cheers,
>> Will
>>   
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-tp17250811p17269729.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Re: PreparedStatement.toString() - nice formatting

Posted by Rick Hillegas <Ri...@Sun.COM>.
Hi Will,

Thanks for bringing this up. I have logged DERBY-3676 to track this 
request. At first blush this looks like a straightforward project for a 
newcomer. If you want to implement this yourself, I would be happy to 
coach you through the code.

Regards,
-Rick

wbecker wrote:
> Is there a way to get a PreparedStatement to tell you what it is going to
> give as a query to the db?
>
> 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. Is there a way to get a similar result with
> Derby? All I seem to get is a string of gibberish, eg:
> :54b48415-0119-ec3b-91d2-000001bca0c8"
>
> Cheers,
> Will
>