Re: [JDBC] Prepare Statement - Mailing list pgsql-sql

From Kris Jurka
Subject Re: [JDBC] Prepare Statement
Date
Msg-id Pine.BSO.4.56.0406171720310.16501@leary.csoft.net
Whole thread Raw
In response to Re: [JDBC] Prepare Statement  ("Jie Liang" <jie@stbernard.com>)
List pgsql-sql

On Thu, 17 Jun 2004, Jie Liang wrote:

> Kris,
> You are right, I modified that piece of code a little bit,
> CallableStatement stmt = conn.prepareCall("{?=call chr(?)}");
> Then my log file were:
> Select * from chr(65) as result;
> Select * from chr(66) as result;
> ......
> However, if I use:
> PrepareStatement stmt = conn.prepareStatement("SELECT chr(?)");
> Then my log file are same as yours.i.e. it use PREPARE and EXECUTE.
>
> So, I am getting confusion.
> I think CallableStatement is extended from PrepareStatement, it should
> have same behaviou.
>

What's happening here is that you can only use prepared statements for
certain operations.  You can't for example prepare a CREATE TABLE
statement.  The driver examines the query to see if it is valid for
preparing and I believe the problem here is that with a callable statement
it is examinging the query with "call" before it is transformed to a
SELECT, so it doesn't recognize it as a preparable.  This looks like a bug
to me.

Kris Jurka


pgsql-sql by date:

Previous
From: Kris Jurka
Date:
Subject: Re: [JDBC] Prepare Statement
Next
From: Kris Jurka
Date:
Subject: Re: [JDBC] Prepare Statement