Thread: JDBC Timestamp problem

JDBC Timestamp problem

From
Antonio Fiol
Date:
Hello,

I have an application that worked well woth Postgresql 6.5.

Now I am on 7.0, and I get this exception when I execute an
rs.getTimestamp("reftime"):

Bad Timestamp Format at 0 in 1970-01-01 01:26:56.99+01
        at
org.postgresql.jdbc1.ResultSet.getTimestamp(ResultSet.java:445)
        at
org.postgresql.jdbc1.ResultSet.getTimestamp(ResultSet.java:587)

Any idea of what it might be ?

Thank you very much !

Antonio Fiol
W3ping


Re: JDBC Timestamp problem

From
Jeff Hoffmann
Date:
Antonio Fiol wrote:
>
> Hello,
>
> I have an application that worked well woth Postgresql 6.5.
>
> Now I am on 7.0, and I get this exception when I execute an
> rs.getTimestamp("reftime"):
>
> Bad Timestamp Format at 0 in 1970-01-01 01:26:56.99+01
>         at
> org.postgresql.jdbc1.ResultSet.getTimestamp(ResultSet.java:445)
>         at
> org.postgresql.jdbc1.ResultSet.getTimestamp(ResultSet.java:587)
>
> Any idea of what it might be ?

it's the timezone part ("+01") that's causing the problems.  it's not
supposed to be there, hence the error in parsing the timestamp.  i've
had the problem before & here's the way i solved it:

 Timestamp expires =
Timestamp.valueOf(rs.getString("field_name").substring(0,19));

there might be a way to alter the output format of the date, but i don't
know how.  maybe peter can help us out there or have some sort of
official response.

--

Jeff Hoffmann
PropertyKey.com

Re: JDBC Timestamp problem

From
Peter T Mount
Date:
Quoting Antonio Fiol <fiol@w3ping.com>:

> Hello,
>
> I have an application that worked well woth Postgresql 6.5.
>
> Now I am on 7.0, and I get this exception when I execute an
> rs.getTimestamp("reftime"):
>
> Bad Timestamp Format at 0 in 1970-01-01 01:26:56.99+01
>         at
> org.postgresql.jdbc1.ResultSet.getTimestamp(ResultSet.java:445)
>         at
> org.postgresql.jdbc1.ResultSet.getTimestamp(ResultSet.java:587)
>
> Any idea of what it might be ?

Yes, there's been a lot of problems with timestamps, mainly where it was
getting confused with timezone/millisecond variations. 99% of these have been
fixed in the 7.1 driver.

(I say 99% as there is bound to be a senario we've missed out ;-) )

Peter


--
Peter Mount peter@retep.org.uk
PostgreSQL JDBC Driver: http://www.retep.org.uk/postgres/
RetepPDF PDF library for Java: http://www.retep.org.uk/pdf/