Received: from carriage.chesco.com (carriage.chesco.com [209.195.192.2]) by hub.org (8.10.1/8.10.1) with ESMTP id e5KLbTM44816 for ; Tue, 20 Jun 2000 17:37:30 -0400 (EDT) Received: from chesco.com (mxfcl9x239.chesco.com [209.195.249.239]) by carriage.chesco.com (8.10.2/8.9.1) with ESMTP id e5KLbGC12009; Tue, 20 Jun 2000 17:37:17 -0400 (EDT) Message-ID: <394FE494.26EAE82C@chesco.com> Date: Tue, 20 Jun 2000 17:39:32 -0400 From: Jim Caley X-Mailer: Mozilla 4.72 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 To: Vincent Trussart CC: petermount@it.maidstone.gov.uk, pgsql-interfaces@postgresql.org Subject: Re: Postgres JDBC driver : problem with timestamps. References: <3947D1F2.B5A931EE@cirano.umontreal.ca> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Archive-Number: 200006/93 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