AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PreparedStatement.toString

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases
View previous topic :: View next topic  
Author Message
Roedy Green
Guest





PostPosted: Sun Jun 13, 2004 8:20 am    Post subject: PreparedStatement.toString Reply with quote



I think a PreparedStatement.toString method would be a great debugging
tool.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Back to top
Chris Smith
Guest





PostPosted: Sun Jun 13, 2004 2:35 pm    Post subject: Re: PreparedStatement.toString Reply with quote



Roedy Green wrote:
Quote:
I think a PreparedStatement.toString method would be a great debugging
tool.

PreparedStatement, of course, inherits a toString method from Object.
Presumably you mean it would be helpful for toString to be specified
with a certain behavior different. I just checked the drivers I'm using
now; in PostgreSQL, it does print the query itself rather than the
default Object notation.

I generally disagree with going out of anyone's way to specify toString
behavior. The toString method is most useful as a debugging tool for
information to be interpreted by human beings; as soon as you define a
format, you lose the chance to include more useful debugging information
about the object state in the future. In the case of PreparedStatement,
which is an interface implemented differently by different drivers, this
is even more of a concern. Sure it'd be easy to save the String used to
create the statement and return that. PostgreSQL, though, also returns
the bound parameters in that String... other implementations may not
keep those bound parameters at runtime, but merely pass them along to
the server.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Back to top
Roedy Green
Guest





PostPosted: Sun Jun 13, 2004 7:15 pm    Post subject: Re: PreparedStatement.toString Reply with quote



On Sun, 13 Jun 2004 08:35:15 -0600, Chris Smith <cdsmith (AT) twu (DOT) net>
wrote or quoted :

Quote:
PreparedStatement, of course, inherits a toString method from Object.

With Resin and MySQL that's all I'm getting.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

Back to top
Joe Weinstein
Guest





PostPosted: Sun Jun 13, 2004 9:36 pm    Post subject: Re: PreparedStatement.toString Reply with quote



Roedy Green wrote:

Quote:
On Sun, 13 Jun 2004 08:35:15 -0600, Chris Smith wrote or quoted :


PreparedStatement, of course, inherits a toString method from Object.

With Resin and MySQL that's all I'm getting.

I have never seen a jdbc driver that implemented any specific information
in the toString() method. I suppose there might be cases where a programmer
would find himself with prepared statements but not know the SQL with which
they were created... In products that allow you to specify what jdbc driver
to use, you could easily tell it to use your own wrapper driver. You wrapper
driver would take the name of the real driver and url etc, and would
return a class of your own that mostly passed all calls to the underlying
real DBMS driver, but for Prepared Statements for instance, it would return
a statement wrapper that also passed most stuff to the wrapper statement,
but implemented it's own toString() method that might say what real statement
was being used, *and* the SQL etc.
Joe Weinstein at BEA


Back to top
Mark Matthews
Guest





PostPosted: Mon Jun 14, 2004 2:50 am    Post subject: Re: PreparedStatement.toString Reply with quote

Roedy Green wrote:
Quote:
On Sun, 13 Jun 2004 08:35:15 -0600, Chris Smith wrote or quoted :

PreparedStatement, of course, inherits a toString method from Object.

With Resin and MySQL that's all I'm getting.

Interseting, since Connector/J's (MySQL's official JDBC driver) as well
as MM.MySQL's (the open source project I started which later became
Connector/J) PreparedStatement.toString() is overriden to provide the
information you're looking for.

Are you using Connector/J or some other JDBC driver for MySQL? Maybe the
wrapper of the connection pool that Resin provides (if you're using one)
doesn't delegate to the JDBC driver's .toString() method?

-Mark


--
Mr. Mark Matthews
MySQL AB, Software Development Manager, J2EE and Windows Platforms
Office: +1 708 332 0507
www.mysql.com

MySQL Guide to Lower TCO
http://www.mysql.com/it-resources/white-papers/tco.php

Back to top
Roedy Green
Guest





PostPosted: Mon Jun 14, 2004 4:45 am    Post subject: Re: PreparedStatement.toString Reply with quote

On Sun, 13 Jun 2004 21:50:21 -0500, Mark Matthews <mark (AT) mysql (DOT) com>
wrote or quoted :

Quote:
Are you using Connector/J or some other JDBC driver for MySQL? Maybe the
wrapper of the connection pool that Resin provides (if you're using one)
doesn't delegate to the JDBC driver's .toString() method?

Caucho Resin has a special MySQL driver, and I'm using a slightly
older version of Resin.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

Back to top
Jacques-Olivier
Guest





PostPosted: Mon Jun 14, 2004 6:08 am    Post subject: Re: PreparedStatement.toString Reply with quote

Hello,

You could you a DebuggableStatement (not part of the standard API), as
described in
<http://www.javaworld.com/javaworld/jw-01-2002/jw-0125-overpower.html>

Jacques-Olivier


Roedy Green wrote:
Quote:
I think a PreparedStatement.toString method would be a great debugging
tool.


Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.