pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-jdbc@postgresql.org
Subject: Inserting into a uuid column
Date: Tue, 03 Mar 2009 22:07:38 +0100
Message-ID: <gok66o$duf$1@ger.gmane.org> (raw)

Hi,

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.

The problem is that the import does not work because Postgres throws an error:

"ERROR: column "guid" is of type uuid but expression is of type character varying"

What I don't understand is that doing an insert with a character literal:

INSERT INTO my_table (guid_column, ...)
VALUES
('a0eebc999c0b4ef8bb6d6bb9bd380a11', ...)

works without problems also when used from within Java.

But the following Java code will throw the above error:

PrparedStatement stmt = connection.prepareStatement(
     "insert into my_table (guid_column) values (?)");
stmt.setObject(1, "a0eebc999c0b4ef8bb6d6bb9bd380a11");
stmt.executeUpdate();


To me this sounds like a problem with the JDBC driver, or am I missing something?

I'm using PG 8.3.5 on Windows XP, the driver is postgresql-8.3-603.jdbc3.jar

Regards
Thomas




view thread (7+ messages)  latest in thread

Message-ID: <gok66o$duf$1@ger.gmane.org>
Permalink:  ../gok66o$duf$1@ger.gmane.org/
Also on:    postgresql.org/message-id/gok66o$duf$1@ger.gmane.org

 · 

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: spam_eater@gmx.net
  Subject: Re: Inserting into a uuid column
  In-Reply-To: <gok66o$duf$1@ger.gmane.org>
  References: <gok66o$duf$1@ger.gmane.org>

* 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