X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id ED800D993E for ; Tue, 27 Sep 2005 21:20:27 -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 79058-05 for ; Wed, 28 Sep 2005 00:20:23 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [131.203.101.226]) by svr1.postgresql.org (Postfix) with ESMTP id E7E4FD98EA for ; Tue, 27 Sep 2005 21:20:22 -0300 (ADT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=[192.168.0.20]) by yass.opencloud.co.nz with asmtp (TLS-1.0:DHE_RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1EKPgK-0007oN-Ij; Wed, 28 Sep 2005 12:20:20 +1200 Message-ID: <4339E1C3.5000800@opencloud.com> Date: Wed, 28 Sep 2005 12:20:19 +1200 From: Oliver Jowett User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Joost Kraaijeveld Cc: Dave Cramer , "pgsql-jdbc@postgresql.org" Subject: Re: Exception storing ipaddress with JBoss after upgrade to References: <1127804795.4050.40.camel@Panoramix> <9A7B5B70-61C1-4573-B3BC-31D991C7B02F@fastcrypt.com> <1127847189.3745.9.camel@Panoramix> In-Reply-To: <1127847189.3745.9.camel@Panoramix> X-Enigmail-Version: 0.90.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.008 required=5 tests=[AWL=0.008] X-Spam-Level: X-Archive-Number: 200509/119 X-Sequence-Number: 13904 Joost Kraaijeveld wrote: > On Tue, 2005-09-27 at 09:48 -0400, Dave Cramer wrote: > >>The new driver uses server side prepared statements and is much more >>particular about the types being sent. >> >>You can force v2 protocol, or create a PGInet type extending PGObject > > I do not really understand why: the postgresql log file shows that the > error is happening at the backend where no Java is running (and I can > also not remember that I had to write special code in ODBC: I just send > a string with a correct ip address and the database backend converted it > to a inet, but that was long ago and I may remember wrong). All examples > in the postgresql docs (e.g. example 11-1 setting up a partial index) > where the inet type is used an ordinary string is passed to the backend. More recent JDBC drivers pass parameters via the extended query protocol which puts the parameter value out-of-band from the query (the query sent to the backend has a $n placeholder where you put the ? in the query, then the parameter values are sent separately). Associated with each parameter is a type. Since you (or rather, JBoss) are telling the JDBC driver that the parameter is a String, it passes the parameter as a text type. There's no implicit cast from text to inet, so the backend complains. It's roughly equivalent to writing out the query with the parameter as '1.2.3.4'::text -- because the type is explicitly specified you don't get the implicit casting of a bare string literal that you'd get otherwise. Or similar to using PREPARE/EXECUTE. Search the pgsql-jdbc archives for more details. -O