pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Vincent Trussart <trussarv@CIRANO.UMontreal.CA>
To: petermount@it.maidstone.gov.uk
To: pgsql-interfaces@postgresql.org
Subject: Postgres JDBC driver : problem with timestamps.
Date: Wed, 14 Jun 2000 14:41:54 -0400
Message-ID: <3947D1F2.B5A931EE@cirano.umontreal.ca> (raw)

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






view thread (3+ messages)  latest in thread

Message-ID: <3947D1F2.B5A931EE@cirano.umontreal.ca>
Permalink:  ../3947D1F2.B5A931EE@cirano.umontreal.ca/
Also on:    postgresql.org/message-id/3947D1F2.B5A931EE@cirano.umontreal.ca

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: trussarv@CIRANO.UMontreal.CA, petermount@it.maidstone.gov.uk
  Subject: Re: Postgres JDBC driver : problem with timestamps.
  In-Reply-To: <3947D1F2.B5A931EE@cirano.umontreal.ca>

* 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