pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: Guillaume <lomig42@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: jdbc and automagic casting
Date: Mon, 19 Sep 2011 14:38:22 -0400 (EDT)
Message-ID: <alpine.BSO.2.00.1109191435330.603@leary.csoft.net> (raw)
In-Reply-To: <419cf418-a33a-4c61-858c-208bf5d55844@g30g2000yqc.googlegroups.com>
References: <419cf418-a33a-4c61-858c-208bf5d55844@g30g2000yqc.googlegroups.com>



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



view thread (5+ messages)  latest in thread

Message-ID: <alpine.BSO.2.00.1109191435330.603@leary.csoft.net>
Permalink:  ../alpine.BSO.2.00.1109191435330.603@leary.csoft.net/
Also on:    postgresql.org/message-id/alpine.BSO.2.00.1109191435330.603@leary.csoft.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: books@ejurka.com, lomig42@gmail.com
  Subject: Re: jdbc and automagic casting
  In-Reply-To: <alpine.BSO.2.00.1109191435330.603@leary.csoft.net>
  References: <419cf418-a33a-4c61-858c-208bf5d55844@g30g2000yqc.googlegroups.com> <alpine.BSO.2.00.1109191435330.603@leary.csoft.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox