From: Kris Jurka <books@ejurka.com>
To: Floyd Shackelford <shackman@fwshackelford.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: bug report: preparedStatement.setObject(indx, "2004-August-15", java.sql.Types.DATE) generates number format exception
Date: Wed, 14 Feb 2007 14:36:15 -0500 (EST)
Message-ID: <Pine.BSO.4.64.0702141433300.24142@leary.csoft.net> (raw)
In-Reply-To: <45D35D00.6020000@fwshackelford.com>
References: <45D35D00.6020000@fwshackelford.com>
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
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: books@ejurka.com, shackman@fwshackelford.com
Subject: Re: bug report: preparedStatement.setObject(indx, "2004-August-15", java.sql.Types.DATE) generates number format exception
In-Reply-To: <Pine.BSO.4.64.0702141433300.24142@leary.csoft.net>
References: <45D35D00.6020000@fwshackelford.com> <Pine.BSO.4.64.0702141433300.24142@leary.csoft.net>
* 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