Skip site navigation (1) Skip section navigation (2)

Re: bug report: preparedStatement.setObject(indx,"2004-August-15",java.sql.Types.DATE) generates number format exception

From: Kris Jurka <books(at)ejurka(dot)com>
To: Floyd Shackelford <shackman(at)fwshackelford(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: bug report: preparedStatement.setObject(indx,"2004-August-15",java.sql.Types.DATE) generates number format exception
Date: 2007-02-14 19:36:15
Message-ID: Pine.BSO.4.64.0702141433300.24142@leary.csoft.net (view raw or flat)
Thread:
Lists: pgsql-jdbc

On Wed, 14 Feb 2007, Floyd Shackelford wrote:

> the following generates a number format exception:
> preparedStatement.setObject(indx,"2004-August-15",java.sql.Types.DATE)
>
> the following works:
> preparedStatement.setObject(indx,"2004-08-15",java.sql.Types.DATE)
>
> i prefer to use the former.
>

I'm not sure that's actually a bug as there are many, many possible date 
formats and the JDBC spec doesn't specify what conversions must be 
supplied.  Do you use this same code on other databases?

Using a SimpleDateFormat object to convert from String to Date yourself is 
the most portable and guaranteed correct method.

Kris Jurka


In response to

pgsql-jdbc by date

Next:From: Jeffrey CoxDate: 2007-02-14 19:40:01
Subject: Re: getProcedureColumns
Previous:From: Chris GamacheDate: 2007-02-14 19:29:06
Subject: Re: stringtype=unspecified problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group