Re: Throwing NumberFormat exception for preparedStatement.setObjcet()

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


Thanks all, Problem resolved :)

-----Original Message-----
From: Kris Jurka [mailto:books(at)ejurka(dot)com]
Sent: Thursday, January 14, 2010 4:07 AM
To: Dave Cramer
Cc: Srinivas Gunnam; pgsql-jdbc(at)postgresql(dot)org
Subject: Re: [JDBC] Throwing NumberFormat exception for preparedStatement.setObjcet()

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

DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Mirco Attocchi 2010-01-14 08:04:17
Previous Message Racker Vijay 2010-01-13 22:39:14 Re: Best Practice to Create a Connection Pool in PostgreSQL