Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 5A57E9FB4A7 for ; Wed, 13 Jun 2007 04:44:30 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 61534-01 for ; Wed, 13 Jun 2007 04:44:23 -0300 (ADT) X-Greylist: delayed 00:24:52.353591 by SQLgrey-1.7.5 Received: from front00.pacwan.net (door0.serverhouse.com [195.200.185.226]) by postgresql.org (Postfix) with ESMTP id 1BC4D9FB877 for ; Wed, 13 Jun 2007 04:44:25 -0300 (ADT) Received: from [10.10.0.6] (108-161-static.pacwan.net [195.200.161.108]) by front00.pacwan.net (Postfix) with ESMTP id 18A8A21C1D7; Wed, 13 Jun 2007 09:19:29 +0200 (CEST) In-Reply-To: <200706130558.l5D5wOl4031981@sprint2.tenix.com> References: <200706130558.l5D5wOl4031981@sprint2.tenix.com> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: multipart/alternative; boundary=Apple-Mail-3--598931057 Message-Id: <43898107-CFD1-422F-8AD9-24AAA20F1B01@entelience.com> Cc: From: Thomas Burdairon Subject: Re: Using INET types in prepared statements in Java? Date: Wed, 13 Jun 2007 09:20:15 +0200 To: LITTLE Nelson X-Mailer: Apple Mail (2.752.2) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/46 X-Sequence-Number: 17108 --Apple-Mail-3--598931057 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=WINDOWS-1252; delsp=yes; format=flowed On Jun 13, 2007, at 07:58, LITTLE Nelson wrote: > Hi, > > > > I am trying to create a prepared statement in JAVA via JDBC and one =20= > of the parameters I need to set in the SQL statement is of type =20 > INET. As there is no setInet() method how do I pass in the INET =20 > value into the sql statement? > > > > I have tried this: > > > > " WHERE b.ip =3D ?::inet" > > > > But I get =93org.postgresql.util.PSQLException: ERROR: cannot cast =20 > type character varying to inet=94 > > > > I also tried > > " WHERE b.ip =3D ?" > > > > And I get =93org.postgresql.util.PSQLException: ERROR: cannot cast =20 > type character varying to inet=94 > > > > I really want to use prepared statement as I have to run this SQL =20 > statement over and over and it is supposed to be more efficient. > > > > Can anyone help? > > > > Cheers, > > Nelson > > > > Hy Nelson Did you try " WHERE b.ip =3D inet(?)" Thomas --Apple-Mail-3--598931057 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=WINDOWS-1252
On Jun 13, 2007, = at 07:58, LITTLE Nelson wrote:

Hi,=A0

I am trying to create a prepared statement in = JAVA via JDBC and one of the parameters I need to set in the SQL = statement is of type INET. As there is no setInet() method how do I pass = in the INET value into the sql statement?

=A0

I have tried this:=A0

"=A0=A0=A0=A0 WHERE b.ip =3D ?::inet"=A0

But I get =93org.postgresql.util.PSQLException: = ERROR: cannot cast type character varying to inet=94=A0

I also tried

"=A0=A0=A0=A0 WHERE b.ip =3D ?"=A0

And I get =93org.postgresql.util.PSQLException: = ERROR: cannot cast type character varying to inet=94=A0

I really want to use prepared statement as I = have to run this SQL statement over and over and it is supposed to be = more efficient.

Can anyone help?

=A0

Cheers,

Nelson

=A0


Hy = Nelson
Did you try
" WHERE b.ip =3D = inet(?)"=A0



Thomas


=

= --Apple-Mail-3--598931057--