Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TsYFP-0000jb-3l for pgsql-jdbc@arkaria.postgresql.org; Tue, 08 Jan 2013 12:25:39 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TsYFO-000204-1F for pgsql-jdbc@arkaria.postgresql.org; Tue, 08 Jan 2013 12:25:38 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TsYFN-0001zz-Cv for pgsql-jdbc@postgresql.org; Tue, 08 Jan 2013 12:25:37 +0000 Received: from [222.73.24.84] (helo=song.cn.fujitsu.com) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TsYFK-0006jd-55 for pgsql-jdbc@postgresql.org; Tue, 08 Jan 2013 12:25:35 +0000 X-IronPort-AV: E=Sophos;i="4.84,431,1355068800"; d="scan'208";a="6544456" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 08 Jan 2013 20:23:27 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r08C1DZJ014656; Tue, 8 Jan 2013 20:01:16 +0800 Received: from [127.0.0.1] ([10.167.159.99]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013010820004183-780120 ; Tue, 8 Jan 2013 20:00:41 +0800 Message-ID: <50EC0A3B.8000601@cn.fujitsu.com> Date: Tue, 08 Jan 2013 19:59:55 +0800 From: Chen Huajun User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Lightning/1.0b2 Thunderbird/3.1.20 MIME-Version: 1.0 To: Dave Cramer CC: List Subject: Re: setObject(int,Object) can not convert Java String object to backend's Integer type References: <50EBFD42.6060401@cn.fujitsu.com> In-Reply-To: X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/01/08 20:00:41, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/01/08 20:00:45, Serialize complete at 2013/01/08 20:00:45 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=UTF-8; format=flowed X-Host-Lookup-Failed: Reverse DNS lookup failed for 222.73.24.84 (failed) X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org Dave > This link http://docs.oracle.com/javase/1.3/docs/guide/jdbc/getstart/mapping.html should clarify things. The mapping is actually String to char, varchar, or longvarchar. oh,I could not find so detailed description in my JDBC 4.0 Specification(a pdf file). And mistaked the setObject(int,Object,int) and setObject(int,Object). BTW: In Oracle,the conversion seem be OK (my test was String -> NUMERIC). That's why i pay attention to this problem. Thanks! Regards, Chen Huajun (2013/01/08 19:15), Dave Cramer wrote: > Chen, > > This link http://docs.oracle.com/javase/1.3/docs/guide/jdbc/getstart/mapping.html should clarify things. The mapping is actually String to char, varchar, or longvarchar. > > Dave > > Dave Cramer > > dave.cramer(at)credativ(dot)ca > http://www.credativ.ca > > > On Tue, Jan 8, 2013 at 6:04 AM, Chen Huajun > wrote: > > 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 > > -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc