Re: uuid values as parameters

From: Florian Weimer <fweimer(at)bfk(dot)de>
To: Lew <noone(at)lewscanon(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: uuid values as parameters
Date: 2010-09-06 12:09:25
Message-ID: 82eid76pl6.fsf@mid.bfk.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

* Lew:

> When you give the SQL parser a string literal, it knows that it might
> have to convert to the column type, and at that can only do so for
> column types that define a conversion for string literals. When you
> give the parser a parameter to a prepared statement, you are adding
> the feature of strong type safety. You are actually depending on the
> parser to reject inputs of the wrong type. For it to accept a string
> value for the parameter would be a violation of that trust.

You usually can work around that by adding a type cast, as in
"?::uuid".

To get behavior which more closely matches those of other PostgreSQL
bindings, add "?stringtype=unspecified" to the JDBC URL.

--
Florian Weimer <fweimer(at)bfk(dot)de>
BFK edv-consulting GmbH http://www.bfk.de/
Kriegsstraße 100 tel: +49-721-96201-1
D-76133 Karlsruhe fax: +49-721-96201-99

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Jochen Terstiege 2010-09-07 15:31:49 JDBC driver method setClob always uses getAsciiStream()
Previous Message Kyran O Reilly 2010-09-02 15:41:20 Re: Can't connect to posgresql through the jdbc driver