X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 997C9529AC for ; Tue, 28 Jun 2005 17:43:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44741-02 for ; Tue, 28 Jun 2005 20:43:31 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id 62AD6529AE for ; Tue, 28 Jun 2005 17:43:29 -0300 (ADT) Received: (qmail 12452 invoked from network); 28 Jun 2005 20:41:33 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (64.7.143.116) by net2.micro-automation.com with SMTP; 28 Jun 2005 20:41:33 -0000 In-Reply-To: <6E0907A94904D94B99D7F387E08C4F57073220@FALCON.INSIGHT> References: <6E0907A94904D94B99D7F387E08C4F57073220@FALCON.INSIGHT> Mime-Version: 1.0 (Apple Message framework v730) Content-Type: multipart/alternative; boundary=Apple-Mail-16--49710459 Message-Id: <9542C79E-EF74-4336-86F6-85D2B140FD6C@fastcrypt.com> Cc: From: Dave Cramer Subject: Re: prepared statement incompatibility Date: Tue, 28 Jun 2005 16:43:30 -0400 To: Byron Nikolaidis X-Mailer: Apple Mail (2.730) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.02 tagged_above=0 required=5 tests=AWL, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200506/147 X-Sequence-Number: 13109 --Apple-Mail-16--49710459 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=WINDOWS-1252; delsp=yes; format=flowed The new driver is more strict about the use of setXXX. Your only =20 option is to use protocol version 2 if you do not want to specify the =20= correct underlying type. You can use setObject(colnumber, String, type ) Dave On 28-Jun-05, at 4:25 PM, Byron Nikolaidis wrote: > Hello all, > > > We are using Postgres 8.0.3, and are attempting to upgrade to the =20 > JDBC 8.x drivers, but have discovered that PreparedStatements that =20 > used to work no longer do so. This is seen where the Java type =20 > does not match the database type, such as attempting to use =20 > preparedStatement.setString(1, =931=94) where the database type is =20= > actually an integer (see stacktrace below). These worked fine =20 > on previous driver versions (such as 7.4). > > > If we set the protocolVersion=3D2, the jdbc 8.x drivers will work =20 > fine also, but I=92m not so sure we really want to do that. > > > At first, I thought this was related to the use of server side =20 > prepares. But I have set the prepareThreshold=3D0 and verified it =20= > was being set by checking for it in the pgconnection and =20 > pgstatement, but it appears to have no effect. > > > Can anyone clarify what exactly has changed with prepared =20 > statements and why it used to work previously? > > > Thanks, > > > Byron > > > Exception in thread "main" java.sql.SQLException: ERROR: column =20 > "ticket" is of type integer but expression is of type character =20 > varying > > at =20 > org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse=20 > (QueryExecutorImpl.java:1471) > > at org.postgresql.core.v3.QueryExecutorImpl.processResults=20 > (QueryExecutorImpl.java:1256) > > at org.postgresql.core.v3.QueryExecutorImpl.execute=20 > (QueryExecutorImpl.java:175) > > at org.postgresql.jdbc2.AbstractJdbc2Statement.execute=20 > (AbstractJdbc2Statement.java:389) > > at =20 > org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags=20 > (AbstractJdbc2Statement.java:330) > > at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate=20= > (AbstractJdbc2Statement.java:282) > > at test.routescape.orm.util.DriverTest.main(DriverTest.java:=20= > 49) > > > --Apple-Mail-16--49710459 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=WINDOWS-1252 The new driver is more strict = about the use of setXXX. Your only option is to use protocol version 2 = if you do not want to specify the correct underlying type.

You can use = setObject(colnumber, String, type )

Dave
On = 28-Jun-05, at 4:25 PM, Byron Nikolaidis wrote:

Hello = all,

=A0

We are using Postgres 8.0.3, and are attempting to upgrade = to the JDBC 8.x drivers, but have discovered that PreparedStatements = that used to work no longer do so.=A0=A0 This is seen where the Java = type does not match the database type, such as attempting to use = preparedStatement.setString(1, =931=94)=A0=A0 where the database type is = actually an integer (see stacktrace below).=A0=A0=A0=A0 These worked = fine on previous driver versions (such as = 7.4).=A0=A0=A0=A0=A0

If we set the protocolVersion=3D2, =A0the jdbc = 8.x drivers will work fine also, but I=92m not so sure we really want to = do that.

At first, I thought this was related to the use = of server side prepares.=A0=A0 But I have set the prepareThreshold=3D0 = and verified it was being set by checking for it in the pgconnection and = pgstatement, but it appears to have no = effect.

=A0

Can anyone clarify what exactly has changed with prepared = statements and why it used to work = previously?=A0=A0=A0

Thanks,

=A0

Byron

Exception in thread "main" = java.sql.SQLException: ERROR: column "ticket" is of type integer but = expression is of type character varying

=A0=A0=A0=A0=A0=A0=A0 at = org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecuto= rImpl.java:1471)

=A0=A0=A0=A0=A0=A0=A0 at = org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.= java:1256)

=A0=A0=A0=A0=A0=A0=A0= at = org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:17= 5)

=A0=A0=A0=A0=A0=A0=A0= at = org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement= .java:389)

=A0=A0=A0=A0=A0=A0=A0= at = org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2= Statement.java:330)

=A0=A0=A0=A0=A0=A0=A0 at = org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Sta= tement.java:282)

=A0=A0=A0=A0=A0=A0=A0 at = test.routescape.orm.util.DriverTest.main(DriverTest.java:49)=

=A0


= --Apple-Mail-16--49710459--