Re: Throwing NumberFormat exception for preparedStatement.setObjcet()

From: Kris Jurka <books(at)ejurka(dot)com>
To: Dave Cramer <pg(at)fastcrypt(dot)com>
Cc: Srinivas Gunnam <srinivas_gunnam(at)persistent(dot)co(dot)in>, "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Throwing NumberFormat exception for preparedStatement.setObjcet()
Date: 2010-01-13 22:36:52
Message-ID: alpine.BSO.2.00.1001131733040.3231@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Tue, 12 Jan 2010, Dave Cramer wrote:

> If I were writing it I would use java.sql.Types.Integer as the
> columnType, not the numeric value. And inputData should be an Integer.
>

inputData can perfectly well be a String. That's the whole point of the
three argument version of this method, to provide such a conversion for
the user.

The reason it's throwing a NumberFormatException is that you're passing
something which isn't a number. With a later driver version you wouldn't
get this exception, but instead the server would complain that it wasn't a
valid number.

The attached test case shows this working just fine from my perspective.

Kris Jurka

Attachment Content-Type Size
SetObjectTest.java text/plain 604 bytes

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Racker Vijay 2010-01-13 22:39:14 Re: Best Practice to Create a Connection Pool in PostgreSQL
Previous Message Dave Cramer 2010-01-12 11:45:17 Re: Throwing NumberFormat exception for preparedStatement.setObjcet()