From: Kris Jurka <books@ejurka.com>
To: Thomas Kellerer <spam_eater@gmx.net>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Inserting into a uuid column
Date: Tue, 3 Mar 2009 16:13:56 -0500 (EST)
Message-ID: <Pine.BSO.4.64.0903031610590.4533@leary.csoft.net> (raw)
In-Reply-To: <gok66o$duf$1@ger.gmane.org>
References: <gok66o$duf$1@ger.gmane.org>
On Tue, 3 Mar 2009, Thomas Kellerer wrote:
> I have a table with a column of type UUID and I would like to import data
> into that table.
>
> I'm using a Java based import tool that will use a PreparedStatement and
> setObject() (passing a String variable) to insert the data.
>
> "ERROR: column "guid" is of type uuid but expression is of type character
> varying"
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.
Alternatively, you can use the 8.4dev JDBC4 driver and issue:
setObject(<column>, <java.util.UUID object>);
> What I don't understand is that doing an insert with a character literal:
>
> INSERT INTO my_table (guid_column, ...)
> VALUES
> ('a0eebc999c0b4ef8bb6d6bb9bd380a11', ...)
Here you aren't providing any specific type information, just a literal.
By saying setString or setObject with a String parameter you are saying
that it really is a String.
Kris Jurka
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, spam_eater@gmx.net
Subject: Re: Inserting into a uuid column
In-Reply-To: <Pine.BSO.4.64.0903031610590.4533@leary.csoft.net>
References: <gok66o$duf$1@ger.gmane.org> <Pine.BSO.4.64.0903031610590.4533@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