Re: jdbc and automagic casting - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: jdbc and automagic casting
Date
Msg-id alpine.BSO.2.00.1109191435330.603@leary.csoft.net
Whole thread Raw
In response to jdbc and automagic casting  (Guillaume <lomig42@gmail.com>)
List pgsql-jdbc

On Mon, 19 Sep 2011, Guillaume wrote:

> INSERT INTO user_record (0, 'abc', '127.0.0.1') is valid and works.
> The string is automagically casted as an inet value.
>
> Using jdbc, this is not the case, and causes me loads of trouble (and
> exceptions).
> Is there a way around it?

If you are using setString with a parameter that's not a string, that's
not correct.  You should use instead setObject(x, y, Types.OTHER).

> I do not have access to the java source code, there is thus no way to
> update the code to programatically force a CAST.

Without access to the source code you can use the connection url parameter
stringtype=unspecified.

http://jdbc.postgresql.org/documentation/head/connect.html#connection-parameters

Kris Jurka

pgsql-jdbc by date:

Previous
From: Kris Jurka
Date:
Subject: Re: binary patch problems
Next
From: Jean-Max Reymond
Date:
Subject: behavior at the end of a transaction