From: Chen Huajun <chenhj@cn.fujitsu.com>
To: List <pgsql-jdbc@postgresql.org>
Subject: setObject(int, Object) can not convert Java String object to backend's Integer type
Date: Tue, 08 Jan 2013 19:04:34 +0800
Message-ID: <50EBFD42.6060401@cn.fujitsu.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
Hi,
According to JDBC Specification Java String object could be converted to
backend's Integer type by setObject().
But in PostgreSQL JDBC, it's not true. It seems to be a bug.
Sample:
PreparedStatement stmt = con.prepareStatement("select 1::int = ?");
stmt.setObject(1, "2");
ResultSet rs = stmt.executeQuery();//raises an error here!
*)but the following is OK
stmt.setObject(1, "2",Types.INTEGER);
stmt.setObject(1, "2",Types.OTHER);
Internally stmt.setObject(1, "2") binds "2" as varchar ,
if it binds "2" as unspecified type,the result will be OK.
Regards,
Chen Huajun
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
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: chenhj@cn.fujitsu.com
Subject: Re: setObject(int, Object) can not convert Java String object to backend's Integer type
In-Reply-To: <50EBFD42.6060401@cn.fujitsu.com>
References: <50EBFD42.6060401@cn.fujitsu.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