Received: from harfang.CC.UMontreal.CA (harfang.CC.UMontreal.CA [132.204.2.102]) by hub.org (8.10.1/8.10.1) with ESMTP id e5EIg5822134 for ; Wed, 14 Jun 2000 14:42:05 -0400 (EDT) Received: from hercule.CIRANO.UMontreal.CA (hercule.CIRANO.UMontreal.CA [132.204.190.26]) by harfang.CC.UMontreal.CA (8.8.8/8.8.8) with ESMTP id OAA09769; Wed, 14 Jun 2000 14:41:57 -0400 (EDT) Received: from cirano.umontreal.ca (comedienne.CIRANO.UMontreal.CA [132.204.190.151]) by hercule.CIRANO.UMontreal.CA (8.9.3/8.9.3) with ESMTP id OAA17036; Wed, 14 Jun 2000 14:41:55 -0400 Message-ID: <3947D1F2.B5A931EE@cirano.umontreal.ca> Date: Wed, 14 Jun 2000 14:41:54 -0400 From: Vincent Trussart Organization: Cirano X-Mailer: Mozilla 4.72 [fr] (X11; U; Linux 2.2.14-1.3.0 i686) X-Accept-Language: fr-CA, fr, en MIME-Version: 1.0 To: petermount@it.maidstone.gov.uk, pgsql-interfaces@postgresql.org Subject: Postgres JDBC driver : problem with timestamps. Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Archive-Number: 200006/84 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