From: | Thomas Kellerer <spam_eater(at)gmx(dot)net> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Inserting into a uuid column |
Date: | 2009-03-03 22:01:16 |
Message-ID: | gok9b9$p4v$1@ger.gmane.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Oliver Jowett | 2009-03-03 22:12:36 | Re: Inserting into a uuid column |
Previous Message | Kris Jurka | 2009-03-03 21:13:56 | Re: Inserting into a uuid column |