Skip site navigation (1) Skip section navigation (2)

Re: Prepare Statement

From: Kris Jurka <books(at)ejurka(dot)com>
To: Jie Liang <jie(at)stbernard(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-sql(at)postgresql(dot)org,pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Prepare Statement
Date: 2004-06-17 22:25:54
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbcpgsql-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

In response to

pgsql-sql by date

Next:From: Jie LiangDate: 2004-06-17 22:50:33
Subject: Re: Prepare Statement
Previous:From: Jie LiangDate: 2004-06-17 20:54:51
Subject: Re: Prepare Statement

pgsql-jdbc by date

Next:From: LizDate: 2004-06-17 22:45:10
Subject: Re: Portable Java Data Layer based on JDBC
Previous:From: Kris JurkaDate: 2004-06-17 22:02:23
Subject: JDK 1.5 beta2 and generics

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group