Using INET types in prepared statements in Java?

Lists: pgsql-jdbc
From: "LITTLE Nelson" <nelson(dot)little(at)tenix(dot)com>
To: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Using INET types in prepared statements in Java?
Date: 2007-06-13 05:58:24
Message-ID: 200706130558.l5D5wOl4031981@sprint2.tenix.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Hi,

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?

I have tried this:

" WHERE b.ip = ?::inet"

But I get "org.postgresql.util.PSQLException: ERROR: cannot cast type
character varying to inet"

I also tried

" WHERE b.ip = ?"

And I get "org.postgresql.util.PSQLException: ERROR: cannot cast type
character varying to inet"

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?

Cheers,

Nelson

Disclaimer :
The contents of this e-mail including any attachments are intended only
for the person or entity to which this e-mail is addressed. If you are not,
or believe you may not be, the intended recipient, please advise the sender
immediately by return e-mail, delete this e-mail and destroy any copies.
Tenix does not warrant nor guarantee that this email communication is free
from errors, virus, interception or interference.


From: Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Using INET types in prepared statements in Java?
Date: 2007-06-13 06:59:23
Message-ID: 200706130959.23766.achill@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Στις Τετάρτη 13 Ιούνιος 2007 08:58, ο/η LITTLE Nelson έγραψε:
> Hi,
>
>
>
> 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?
>
>
>
> I have tried this:
>
>
>
> " WHERE b.ip = ?::inet"

Did you try

WHERE b.ip = ?::text::inet"

?
>
>
>
> But I get "org.postgresql.util.PSQLException: ERROR: cannot cast type
> character varying to inet"
>
>
>
> I also tried
>
> " WHERE b.ip = ?"
>
>
>
> And I get "org.postgresql.util.PSQLException: ERROR: cannot cast type
> character varying to inet"
>
>
>
> 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?
>
>
>
> Cheers,
>
> Nelson
>
>
>
>
>
> Disclaimer :
> The contents of this e-mail including any attachments are intended only
> for the person or entity to which this e-mail is addressed. If you are
> not, or believe you may not be, the intended recipient, please advise the
> sender immediately by return e-mail, delete this e-mail and destroy any
> copies. Tenix does not warrant nor guarantee that this email communication
> is free from errors, virus, interception or interference.

--
Achilleas Mantzios


From: Thomas Burdairon <tburdairon(at)entelience(dot)com>
To: LITTLE Nelson <nelson(dot)little(at)tenix(dot)com>
Cc: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Using INET types in prepared statements in Java?
Date: 2007-06-13 07:20:15
Message-ID: 43898107-CFD1-422F-8AD9-24AAA20F1B01@entelience.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc


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
> 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?
>
>
>
> I have tried this:
>
>
>
> " WHERE b.ip = ?::inet"
>
>
>
> But I get “org.postgresql.util.PSQLException: ERROR: cannot cast
> type character varying to inet”
>
>
>
> I also tried
>
> " WHERE b.ip = ?"
>
>
>
> And I get “org.postgresql.util.PSQLException: ERROR: cannot cast
> type character varying to inet”
>
>
>
> 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?
>
>
>
> Cheers,
>
> Nelson
>
>
>
>
Hy Nelson
Did you try
" WHERE b.ip = inet(?)"

Thomas