Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id BA71463409A for ; Tue, 3 Mar 2009 17:14:01 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 80612-03 for ; Tue, 3 Mar 2009 17:13:58 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from leary.csoft.net (leary.csoft.net [205.205.214.5]) by mail.postgresql.org (Postfix) with ESMTP id C86C7634086 for ; Tue, 3 Mar 2009 17:13:58 -0400 (AST) Received: by leary.csoft.net (Postfix, from userid 1112) id CC28DA99C; Tue, 3 Mar 2009 16:13:56 -0500 (EST) Date: Tue, 3 Mar 2009 16:13:56 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Thomas Kellerer cc: pgsql-jdbc@postgresql.org Subject: Re: Inserting into a uuid column In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200903/10 X-Sequence-Number: 19340 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(, , 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(, ); > 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