X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 7A93B9DCAC4 for ; Tue, 6 Dec 2005 08:52:56 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05850-01 for ; Tue, 6 Dec 2005 08:52:59 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by postgresql.org (Postfix) with SMTP id 91EAC9DCAC3 for ; Tue, 6 Dec 2005 08:52:53 -0400 (AST) Received: (qmail 25170 invoked from network); 6 Dec 2005 12:52:56 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 6 Dec 2005 12:52:56 -0000 In-Reply-To: <00b001c5fa45$123f1a60$0f01a8c0@zaphod> References: <024401c5f9da$537c29c0$0f01a8c0@zaphod> <00b001c5fa45$123f1a60$0f01a8c0@zaphod> Mime-Version: 1.0 (Apple Message framework v746.2) X-Priority: 3 Content-Type: multipart/alternative; boundary=Apple-Mail-32-947551983 Message-Id: Cc: "Kris Jurka" , From: Dave Cramer Subject: Re: Problem with 8.1 driver Date: Tue, 6 Dec 2005 07:52:54 -0500 To: Michael Paesold X-Mailer: Apple Mail (2.746.2) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.257 required=5 tests=[HTML_FONT_BIG=0.256, HTML_MESSAGE=0.001] X-Spam-Score: 0.257 X-Spam-Level: X-Archive-Number: 200512/22 X-Sequence-Number: 14353 --Apple-Mail-32-947551983 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed The latest CVS has a parameter (stringtype = String) in the URL to send strings as unknown See http://jdbc.postgresql.org/documentation/head/ connect.html#connection-parameters for details. Dave On 6-Dec-05, at 4:11 AM, Michael Paesold wrote: > Kris Jurka wrote: > >> On Mon, 5 Dec 2005, Michael Paesold wrote: >> >>> Hi, >>> >>> I am running postgresql-8.1-404.jdbc3.jar against server version >>> 7.4.7, which I want to eventually upgrade to 8.1. >>> >>> String DELETE_QUERY = "DELETE FROM server_log WHERE level_value" >>> + " <= ? AND event_time < NOW() - interval ?"; >>> >> >> The syntax "interval ?" may not be used in prepared queries. This >> is a limitation of the backend which you can see using PREPARE/ >> EXECUTE at the SQL level. The 8.0 driver started using true >> prepared queries instead of directly interpolating parameter >> values and issuing a regular sql statement. You must use "CAST(? >> AS INTERVAL)" or "?::interval". > > Ah, I understand. > > PREPARE p1 (integer,interval) AS DELETE FROM server_log > WHERE level_value <= $1 AND event_time < NOW() - interval $2; > ERROR: syntax error at or near "$2" at character 118 > > After playing with ?protocolVersion I figured that the new driver > is using the real V3 protocol. Using V2 (with the driver parsing > the arguments, the query works just fine). > > Another question that occurred to me is, how should I tell the > driver to specify a type as "undefined" or "unknown" to the server? > > Some random tries that did not work: > stmt.setObject(2, "1 month", java.sql.Types.OTHER); > --> Cannot cast an instance of String to type Types.OTHER > > stmt.setObject(2, new PGUnknown("1 month")); > --> don't know type for PGUnknown; use setObject(int,Object,int) > > stmt.setObject(2, new PGUnknown("1 month"), Types.OTHER); > Cannot cast an instance of PGUnknown to type Types.OTHER > > I guess there is currently no way to do this? > > Best Regards, > Michael Paesold > > > ---------------------------(end of > broadcast)--------------------------- > TIP 1: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that > your > message can get through to the mailing list cleanly > --Apple-Mail-32-947551983 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=ISO-8859-1 The latest CVS has a parameter = (stringtype =3D String)=A0 in the URL to = send strings as unknown


Dave

= On 6-Dec-05, at 4:11 AM, Michael Paesold wrote:

Kris Jurka wrote:

On Mon, 5 Dec 2005, Michael Paesold wrote:

Hi,

I am running = postgresql-8.1-404.jdbc3.jar against server version 7.4.7, which I want = to eventually upgrade to 8.1.

String DELETE_QUERY =3D "DELETE = FROM server_log WHERE level_value"
=A0 + " <=3D ? AND event_time = < NOW() - interval ?";


The syntax "interval ?" may not = be used in prepared queries.=A0 = This is a limitation of the backend which you can see using = PREPARE/EXECUTE at the SQL level.=A0= The 8.0 driver started using true prepared queries instead of = directly interpolating parameter values and issuing a regular sql = statement.=A0 You must use = "CAST(? AS INTERVAL)" or "?::interval".

Ah, I = understand.

PREPARE p1 (integer,interval) AS DELETE FROM = server_log
WHERE level_value=A0 <=3D $1 AND event_time = < NOW() - interval $2;
ERROR:=A0 syntax error at or near "$2" = at character 118

After playing with ?protocolVersion I figured that = the new driver is using the real V3 protocol. Using V2 (with the driver = parsing the arguments, the query works just fine).

Another = question that occurred to me is, how should I tell the driver to specify = a type as "undefined" or "unknown" to the server?

Some = random tries that did not work:
--> Cannot cast an instance of String to type = Types.OTHER

stmt.setObject(2, new PGUnknown("1 = month"));
--> don't know type for = PGUnknown; use setObject(int,Object,int)

Cannot cast an instance of PGUnknown to type = Types.OTHER

I guess there is currently no way to do = this?

Best Regards,
Michael = Paesold=A0


TIP 1: = if posting/reading through Usenet, please send an appropriate
=A0 =A0 =A0 = subscribe-nomail command to majordomo@postgresql.org so = that your
=A0 =A0 =A0 message can get = through to the mailing list cleanly


= --Apple-Mail-32-947551983--