Re: How to get the SQL query from a PreparedStatement?

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Andres Olarte <olarte(dot)andres(at)gmail(dot)com>
Cc: "Pgsql-Jdbc(at)Postgresql(dot)Org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: How to get the SQL query from a PreparedStatement?
Date: 2007-11-06 07:45:46
Message-ID: 47301BAA.1000804@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Andres Olarte wrote:

> Is it possible to get the query string (including the formatted
> parameters) from a PreparedStatement?

In general you can't because the query's not sent like that (the
parameter values are sent out of line from the query).

IIRC, PreparedStatement.toString() will give you an approximation, but
I'm not sure how accurate the results are (and it's not part of the spec)

-O

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Phillip Mills 2007-11-06 14:09:35 Beginning tuning
Previous Message Kevin Neufeld 2007-11-06 04:47:03 Re: Parsed Query Trees