pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Bert Hiri <bert@openwiki.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: PreparedStatement.setString
Date: Fri, 22 Apr 2005 20:12:37 +1200
Message-ID: <4268B1F5.1080302@opencloud.com> (raw)
In-Reply-To: <4150.82.94.255.26.1114152247.squirrel@webmail.high5.net>
References: <4150.82.94.255.26.1114152247.squirrel@webmail.high5.net>

Bert Hiri wrote:

>     PreparedStatement stmt =
>         con.prepareStatement("INSERT INTO test(id) VALUES (?)");
>     stmt.setString("12345");
>     stmt.executeUpdate();
> 
> This will fail. With the message:
> 
>     Cause: ERROR: column "id" is of type numeric but expression is of type
> character varying
> 
> I think this shouldn't fail. This exact same piece of Java code does work
> with all other databases that I work with. And psql doesn't seem to mind
> taking a string value either, so why should the PreparedStatement?

See http://archives.postgresql.org/pgsql-jdbc/2005-03/msg00060.php for
past discussion of this.

In summary: it might be a common idiom, but the JDBC spec doesn't
require drivers to support it, and there are protocol-level reasons why
it is not easy to support.

-O



view thread (2+ messages)

Message-ID: <4268B1F5.1080302@opencloud.com>
Permalink:  ../4268B1F5.1080302@opencloud.com/
Also on:    postgresql.org/message-id/4268B1F5.1080302@opencloud.com

 · 

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: oliver@opencloud.com, bert@openwiki.com
  Subject: Re: PreparedStatement.setString
  In-Reply-To: <4268B1F5.1080302@opencloud.com>
  References: <4150.82.94.255.26.1114152247.squirrel@webmail.high5.net> <4268B1F5.1080302@opencloud.com>

* 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