Inserting into a uuid column - Mailing list pgsql-jdbc

From Thomas Kellerer
Subject Inserting into a uuid column
Date
Msg-id gok66o$duf$1@ger.gmane.org
Whole thread Raw
Responses Re: Inserting into a uuid column
List pgsql-jdbc
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

pgsql-jdbc by date:

Previous
From: Віталій Тимчишин
Date:
Subject: Re: ResultSetMetaData.getColumnDisplaySize returns 2147483647 ?
Next
From: Kris Jurka
Date:
Subject: Re: Inserting into a uuid column