pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Postgres JDBC driver : problem with timestamps.
3+ messages / 3 participants
[nested] [flat]

* Postgres JDBC driver : problem with timestamps.
@ 2000-06-14 18:41 Vincent Trussart <trussarv@CIRANO.UMontreal.CA>
  2000-06-20 21:39 ` Re: Postgres JDBC driver : problem with timestamps. Jim Caley <caley@chesco.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Vincent Trussart @ 2000-06-14 18:41 UTC (permalink / raw)
  To: petermount@it.maidstone.gov.uk; pgsql-interfaces

Using the JDBC drivers (for 1.2) from the postgresql-7.0.2 rpm
distribution
I cannot read back a timestamp value I just inserted in a column (column
type "timestamp")
with the same application.  This little java code fails :

---------------------------
import java.sql.*;

public class test {

    public static void main(String[] args) throws Exception {

        Class.forName("org.postgresql.Driver").newInstance();
        Connection conn =
DriverManager.getConnection("jdbc:postgresql://localhost/test", "test",
"");
        PreparedStatement stmt = conn.prepareStatement("insert into test
values (?)");
        stmt.setTimestamp(1, new Timestamp(System.currentTimeMillis()));

        stmt.executeUpdate();

        Statement reader = conn.createStatement();
        ResultSet rs = reader.executeQuery("select * from test");
        while (rs.next()){
            System.out.println(rs.getTimestamp(1));
        }
    }
}




Running this code gives :

Exception in thread "main" Bad Timestamp Format at 19 in 2000-06-14
14:32:40.46-04
 at org.postgresql.jdbc2.ResultSet.getTimestamp(ResultSet.java:447)
 at test.main(test.java:18)



Any idea?



--
Vincent Trussart
trussarv@cirano.umontreal.ca
Cirano
Québec






^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Postgres JDBC driver : problem with timestamps.
  2000-06-14 18:41 Postgres JDBC driver : problem with timestamps. Vincent Trussart <trussarv@CIRANO.UMontreal.CA>
@ 2000-06-20 21:39 ` Jim Caley <caley@chesco.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Jim Caley @ 2000-06-20 21:39 UTC (permalink / raw)
  To: Vincent Trussart <trussarv@CIRANO.UMontreal.CA>; +Cc: petermount@it.maidstone.gov.uk; pgsql-interfaces

Hi Vincent,

We had a discussion on this very issue on this mailing list last week. 
If you go to
http://www.postgresql.org/mhonarc/pgsql-interfaces/2000-06/threads.html
and search the page for "Timestamps" you'll see the thread.  The first
message in the thread includes a patch that's been working for me.

HTH

Regards,
Jim
--

Vincent Trussart wrote:
> 
> Using the JDBC drivers (for 1.2) from the postgresql-7.0.2 rpm
> distribution
> I cannot read back a timestamp value I just inserted in a column (column
> type "timestamp")
> with the same application.  This little java code fails :
> 
> ---------------------------
> import java.sql.*;
> 
> public class test {
> 
>     public static void main(String[] args) throws Exception {
> 
>         Class.forName("org.postgresql.Driver").newInstance();
>         Connection conn =
> DriverManager.getConnection("jdbc:postgresql://localhost/test", "test",
> "");
>         PreparedStatement stmt = conn.prepareStatement("insert into test
> values (?)");
>         stmt.setTimestamp(1, new Timestamp(System.currentTimeMillis()));
> 
>         stmt.executeUpdate();
> 
>         Statement reader = conn.createStatement();
>         ResultSet rs = reader.executeQuery("select * from test");
>         while (rs.next()){
>             System.out.println(rs.getTimestamp(1));
>         }
>     }
> }
> 
> Running this code gives :
> 
> Exception in thread "main" Bad Timestamp Format at 19 in 2000-06-14
> 14:32:40.46-04
>  at org.postgresql.jdbc2.ResultSet.getTimestamp(ResultSet.java:447)
>  at test.main(test.java:18)
> 
> Any idea?
> 
> --
> Vincent Trussart
> trussarv@cirano.umontreal.ca
> Cirano
> Québec



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* RE: Postgres JDBC driver : problem with timestamps.
@ 2000-06-26 08:02 Peter Mount <petermount@it.maidstone.gov.uk>
  0 siblings, 0 replies; 3+ messages in thread

From: Peter Mount @ 2000-06-26 08:02 UTC (permalink / raw)
  To: 'Vincent Trussart' <trussarv@CIRANO.UMontreal.CA>; Peter Mount <petermount@it.maidstone.gov.uk>; pgsql-interfaces

This was fixed a couple of weeks ago...

--
Peter Mount
Enterprise Support
Maidstone Borough Council
Any views stated are my own, and not those of Maidstone Borough Council


-----Original Message-----
From: Vincent Trussart [mailto:trussarv@CIRANO.UMontreal.CA]
Sent: Wednesday, June 14, 2000 7:42 PM
To: petermount@it.maidstone.gov.uk; pgsql-interfaces@postgresql.org
Subject: [INTERFACES] Postgres JDBC driver : problem with timestamps.


Using the JDBC drivers (for 1.2) from the postgresql-7.0.2 rpm
distribution
I cannot read back a timestamp value I just inserted in a column (column
type "timestamp")
with the same application.  This little java code fails :

---------------------------
import java.sql.*;

public class test {

    public static void main(String[] args) throws Exception {

        Class.forName("org.postgresql.Driver").newInstance();
        Connection conn =
DriverManager.getConnection("jdbc:postgresql://localhost/test", "test",
"");
        PreparedStatement stmt = conn.prepareStatement("insert into test
values (?)");
        stmt.setTimestamp(1, new Timestamp(System.currentTimeMillis()));

        stmt.executeUpdate();

        Statement reader = conn.createStatement();
        ResultSet rs = reader.executeQuery("select * from test");
        while (rs.next()){
            System.out.println(rs.getTimestamp(1));
        }
    }
}




Running this code gives :

Exception in thread "main" Bad Timestamp Format at 19 in 2000-06-14
14:32:40.46-04
 at org.postgresql.jdbc2.ResultSet.getTimestamp(ResultSet.java:447)
 at test.main(test.java:18)



Any idea?



--
Vincent Trussart
trussarv@cirano.umontreal.ca
Cirano
Québec





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2000-06-26 08:02 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-06-14 18:41 Postgres JDBC driver : problem with timestamps. Vincent Trussart <trussarv@CIRANO.UMontreal.CA>
2000-06-20 21:39 ` Jim Caley <caley@chesco.com>
2000-06-26 08:02 RE: Postgres JDBC driver : problem with timestamps. Peter Mount <petermount@it.maidstone.gov.uk>

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