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

Re: PG 8.0.3 - PreparedStatement Can't Use Query Methods

From: Kris Jurka <books(at)ejurka(dot)com>
To: David Wall <d(dot)wall(at)computer(dot)org>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: PG 8.0.3 - PreparedStatement Can't Use Query Methods
Date: 2005-08-10 16:50:36
Message-ID: Pine.BSO.4.56.0508101148520.20899@leary.csoft.net (view raw or flat)
Thread:
Lists: pgsql-jdbc

On Wed, 10 Aug 2005, David Wall wrote:

> We are converting from a 7.3 PG database to 8.0.3 and mostly all is 
> working okay.  We are using postgresql-8.1dev-400.jdbc3.jar for JDBC.
> 
> Previously, we never received this sort of error.  The idea is that 
> certain SQLExceptions are passed to a routine in our connection pool 
> that attempts to see if the Connection object is still valid or not by 
> doing a simple SELECT 1 command.  This command still works fine via psql.
> 
> org.postgresql.util.PSQLException: Can''t use query methods that take a 
> query string on a PreparedStatement.
>         at 
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:218)
>         at 
> 
> What am I doing wrong here?  It seems so straightforward.  We create a 
> preparedStatement with a simple SELECT and then execute the query and 
> ignore the result set that may come back.
> 

The JDBC 3 Spec 13.2.4 says, "If any of the PreparedStatement execute 
methods is called with an SQL string as a parameter, an SQLException is 
thrown."

Kris Jurka

In response to

Responses

pgsql-jdbc by date

Next:From: David WallDate: 2005-08-10 17:18:08
Subject: Re: PG 8.0.3 - PreparedStatement Can't Use Query Methods exception
Previous:From: David WallDate: 2005-08-10 16:41:01
Subject: PG 8.0.3 - PreparedStatement Can't Use Query Methods exception

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