pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Display SQL from Java Prepared Statement
5+ messages / 4 participants
[nested] [flat]

* Display SQL from Java Prepared Statement
@ 2009-08-22 12:53  Campbell, Lance <lance@illinois.edu>
  0 siblings, 1 reply; 5+ messages in thread

From: Campbell, Lance @ 2009-08-22 12:53 UTC (permalink / raw)
  To: pgsql-jdbc

Is there a way I can have the JDBC driver dump out to a log file all of
the SQL statements executed?  I am using prepared statements.

Note:  I think the development team is doing a great job.

Thanks,

Lance Campbell
Project Manager/Software Architect/DBA
Web Services at Public Affairs
217-333-0382

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Display SQL from Java Prepared Statement
@ 2009-08-23 16:31  J. W. Ulbts <magog001@web.de>
  parent: Campbell, Lance <lance@illinois.edu>
  0 siblings, 1 reply; 5+ messages in thread

From: J. W. Ulbts @ 2009-08-23 16:31 UTC (permalink / raw)
  To: pgsql-jdbc

Hi Lance!

>Is there a way I can have the JDBC driver dump out to a log file all 
> of the SQL statements executed? I am using prepared statements.
> Note: I think the development team is doing a great job.
> Thanks,
> Lance Campbell

Just call the toString() method of the prepared statement object. That will print the prepared statements SQL. It includes not just the SQL command but also some additional text before the SQL command.
I'm using it also to write statements to the log.

Kind regards,
J. Ulbts
______________________________________________________
GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://movieflat.web.de




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Display SQL from Java Prepared Statement
@ 2009-08-24 03:23  Campbell, Lance <lance@illinois.edu>
  parent: J. W. Ulbts <magog001@web.de>
  0 siblings, 1 reply; 5+ messages in thread

From: Campbell, Lance @ 2009-08-24 03:23 UTC (permalink / raw)
  To: J. W. Ulbts <magog001@web.de>; pgsql-jdbc

J,
I thought I had tried that before.  Good grief that was way to obvious.

I cannot even begin to thank you enough.  Thanks for the response. 


Thanks,

Lance Campbell
Project Manager/Software Architect/DBA
Web Services at Public Affairs
217-333-0382

-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of J. W. Ulbts
Sent: Sunday, August 23, 2009 11:31 AM
To: pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] Display SQL from Java Prepared Statement

Hi Lance!

>Is there a way I can have the JDBC driver dump out to a log file all  
>of the SQL statements executed? I am using prepared statements.
> Note: I think the development team is doing a great job.
> Thanks,
> Lance Campbell

Just call the toString() method of the prepared statement object. That will print the prepared statements SQL. It includes not just the SQL command but also some additional text before the SQL command.
I'm using it also to write statements to the log.

Kind regards,
J. Ulbts
______________________________________________________
GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://movieflat.web.de


--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Display SQL from Java Prepared Statement
@ 2011-08-22 03:00  vanayya <nurmi_isnayati@yahoo.com>
  parent: Campbell, Lance <lance@illinois.edu>
  0 siblings, 1 reply; 5+ messages in thread

From: vanayya @ 2011-08-22 03:00 UTC (permalink / raw)
  To: pgsql-jdbc

But its not working for me ..

I have written like this :

/
 PreparedStatement pStatement = null;
 ....

 pStatement = connection.prepareStatement(" update tblMember set address =
?");
 pStatement.setObject(i++, "Jl. Setya Budi");
 System.out.println("query : " + pStatement.toString());

/

And the result : 

/query : org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement@1c1de1c/

I need log query from pStatement, Does anyone can help me ? 

regard,

mimi

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Display-SQL-from-Java-Prepared-Statement-tp2175579p4721914.h...
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Display SQL from Java Prepared Statement
@ 2011-08-22 13:04  Oliver Jowett <oliver@opencloud.com>
  parent: vanayya <nurmi_isnayati@yahoo.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Oliver Jowett @ 2011-08-22 13:04 UTC (permalink / raw)
  To: vanayya <nurmi_isnayati@yahoo.com>; +Cc: pgsql-jdbc

On 22 August 2011 15:00, vanayya <nurmi_isnayati@yahoo.com> wrote:

> /query : org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement@1c1de1c/

You are using a connection pool that wraps the statement object.
You'll need to unwrap it, or modify the connection pool's
implementation so that toString() delegates to the underlying
statement.

Oliver



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2011-08-22 13:04 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-08-22 12:53 Display SQL from Java Prepared Statement Campbell, Lance <lance@illinois.edu>
2009-08-23 16:31 ` J. W. Ulbts <magog001@web.de>
2009-08-24 03:23   ` Campbell, Lance <lance@illinois.edu>
2011-08-22 03:00     ` vanayya <nurmi_isnayati@yahoo.com>
2011-08-22 13:04       ` Oliver Jowett <oliver@opencloud.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox