Re: Inserting into a uuid column - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: Inserting into a uuid column
Date
Msg-id Pine.BSO.4.64.0903031713180.19272@leary.csoft.net
Whole thread Raw
In response to Re: Inserting into a uuid column  (Thomas Kellerer <spam_eater@gmx.net>)
Responses Re: Inserting into a uuid column  (Thomas Kellerer <spam_eater@gmx.net>)
List 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

pgsql-jdbc by date:

Previous
From: Oliver Jowett
Date:
Subject: Re: Inserting into a uuid column
Next
From: Oliver Jowett
Date:
Subject: Re: Inserting into a uuid column