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: Re: Inserting into a uuid column
Date: Tue, 03 Mar 2009 23:01:16 +0100
Message-ID: <gok9b9$p4v$1@ger.gmane.org> (raw)
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>

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.

>> 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.

No I'm not using setString() in that example. The Java code would be:

Statement stmt = connection.createStatement();
stmt.executeUpdate("INSERT INTO my_table (guid_column) " +
" VALUES ('a0eebc999c0b4ef8bb6d6bb9bd380a11')");

So it's passing a literal and is not using a PreparedStatement

The Javadocs of setObject(int, Object) say:

"The given argument will be converted to the corresponding SQL type before being 
sent to the database"

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).

Regards
Thomas




view thread (7+ messages)  latest in thread

Message-ID: <gok9b9$p4v$1@ger.gmane.org>
Permalink:  ../gok9b9$p4v$1@ger.gmane.org/
Also on:    postgresql.org/message-id/gok9b9$p4v$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: <gok9b9$p4v$1@ger.gmane.org>
  References: <gok66o$duf$1@ger.gmane.org> <Pine.BSO.4.64.0903031610590.4533@leary.csoft.net> <gok9b9$p4v$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