Re: Inserting into a uuid column

From: Kris Jurka <books(at)ejurka(dot)com>
To: Thomas Kellerer <spam_eater(at)gmx(dot)net>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Inserting into a uuid column
Date: 2009-03-03 22:29:05
Message-ID: Pine.BSO.4.64.0903031713180.19272@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Tue, 3 Mar 2009, Thomas Kellerer wrote:

> Kris Jurka wrote on 03.03.2009 22:13:
>> You should use setObject(<column>, <string value>, Types.OTHER) to indicate
>> that while you are passing a String, you aren't expecting the server type
>> to be a string datatype.
>
> The problem is that this is a generic import tool, but I'll see what I can
> do.

The other option is to use the URL parameter stringtype=unspecified if you
cannot change the underlying code.

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

> So I was expecting that the driver will be able to do the same conversion
> with the PreparedStatement as it is obviously happening when using a literal
> (though that conversion probably takes place on the server not in the
> driver).

The reason the driver doesn't do this is twofold.

1) The driver doesn't know the target server type. Retrieving that would
induce an extra network roundtrip for execution.

2) Sometimes the server doesn't know the the target type and it's better
for the driver/user to provide it. Consider the call of an overloaded
function: SELECT myfunc(?), if it has an implementation for both float and
int, you want the user/driver to indicate which one should be called
because the server doesn't know.

Kris Jurka

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2009-03-03 22:53:23 Re: Inserting into a uuid column
Previous Message Oliver Jowett 2009-03-03 22:12:36 Re: Inserting into a uuid column