Re: Bad Timestamp Format

From: "Thomas O'Dowd" <tom(at)nooper(dot)com>
To: "G(dot)Nagarajan" <gnagarajan(at)dkf(dot)de>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Bad Timestamp Format
Date: 2002-01-27 05:50:13
Message-ID: 20020127145013.G8130@beast.uwillsee.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc

Hi Nagarajan,

On Sat, Jan 26, 2002 at 05:14:31PM +0100, G.Nagarajan wrote:
> Hi Tom,
>
> I went to ResultSet.java and made all the formats into
> df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
>
> so now it works. As I don't require the seconds and milliseconds part,
> it is ok now.

Hmmmmmm. Not sure that this is the correct solution for your particular
problem (ie. altering the driver) although it may work for you now. It
would be better to find out the core of the problem and fix that.

> my program inserts the date values in the "yyyy-MM-dd HH:mm" format.
> Perhaps that is causing the problem. However I am not changing the
> default format either in the driver or in the database.

What database version are you using? What driver version are you using?
I can't figure out how to get 7.2 beta to return a shorter timestamp
then 1970-01-01 00:00:00. even if I insert a short timestamp. I presume
you are using older code? As I said before, the driver should force
the datestyle to ISO when it first gets a connection.

select '1970-1-1 0:0'::timestamp without time zone, '1970-1-1 0:0'::timestamp;
timestamp | timestamptz
---------------------+------------------------
1970-01-01 00:00:00 | 1970-01-01 00:00:00+09
(1 row)

If I can figure out how you are doing it and if the its a problem in the
latest code, then we can fix it.

Tom.

> -----Original Message-----
> From: pgsql-jdbc-owner(at)postgresql(dot)org
> [mailto:pgsql-jdbc-owner(at)postgresql(dot)org]On Behalf Of Thomas O'Dowd
> Sent: Saturday, January 26, 2002 4:47 PM
> To: Gunaseelan Nagarajan
> Cc: pgsql-jdbc(at)postgresql(dot)org
> Subject: Re: [JDBC] Bad Timestamp Format
>
>
> Hi Nagarajan,
>
> What driver version are you using? The latest drivers at least
> should switch the database to return ISO datestyle timestamps
> when it first gets a connection. The current driver code expects
> to parse the ISO format which is why you are getting this exception
> below. Are you changing the datestyle in your program? I'm unfamilar
> with how to get postgres to return a timestamp in the short format without
> the seconds which you have below. The ISO format usually returns...
> 1970-01-01 00:00:00 if without time zone is specified. Can you perhaps
> provide sample code that reproduces the problem using the latest driver?
>
> You can download the latest drivers here...
>
> http://jdbc.postgresql.org/download.html
>
> Cheers,
>
> Tom.
>
> On Sat, Jan 26, 2002 at 02:33:15PM +0100, Gunaseelan Nagarajan wrote:
> > hi,
> > I get the following error while retrieving a datetime column using
> > getTimestamp.
> >
> > Bad Timestamp Format at 12 in 1970-1-1 0:0;
> >
> >
> > Bad Timestamp Format at 12 in 1970-1-1 0:0
> > at org.postgresql.jdbc2.ResultSet.getTimestamp(Unknown Source)
> > at org.postgresql.jdbc2.ResultSet.getTimestamp(Unknown Source)
> > at
> > org.jboss.pool.jdbc.ResultSetInPool.getTimestamp(ResultSetInPool.java:734)
> >
> > regards,
> > Nagarajan.
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 5: Have you checked our extensive FAQ?
> >
> > http://www.postgresql.org/users-lounge/docs/faq.html
>
> --
> Thomas O'Dowd. - Nooping - http://nooper.com
> tom(at)nooper(dot)com - Testing - http://nooper.co.jp/labs
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

--
Thomas O'Dowd. - Nooping - http://nooper.com
tom(at)nooper(dot)com - Testing - http://nooper.co.jp/labs

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Don Baccus 2002-01-27 07:04:38 Re: PostgreSQL v7.2rc2 Released
Previous Message Marc G. Fournier 2002-01-27 05:49:28 PostgreSQL v7.2rc2 Released

Browse pgsql-jdbc by date

  From Date Subject
Next Message Gunaseelan Nagarajan 2002-01-27 14:22:58 Re: Bad Timestamp Format
Previous Message M. A. Sridhar 2002-01-27 05:36:35 Re: Continuing problems with using OIDs via JDBC (solved)