X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E0A75D95BA for ; Fri, 4 Nov 2005 15:27:24 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45937-07 for ; Fri, 4 Nov 2005 19:27:10 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from svr2.postgresql.org (svr2.postgresql.org [65.19.161.25]) by svr1.postgresql.org (Postfix) with ESMTP id E845FD99A2 for ; Fri, 4 Nov 2005 15:27:10 -0400 (AST) Received: from mail.diuno.com.br (unknown [200.175.102.226]) by svr2.postgresql.org (Postfix) with ESMTP id 18A61F14D4 for ; Fri, 4 Nov 2005 18:38:34 +0000 (GMT) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: 7.3 -> 8.0.4 migration timestamp problem Date: Fri, 4 Nov 2005 16:35:34 -0200 Message-ID: <54CC7CADE26E884EB2BCEC863F5C1F70F9D263@moscou.diuno.net> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: 7.3 -> 8.0.4 migration timestamp problem Thread-Index: AcXhbosc8afi4nSjQOGoHLVi8kDDSQ== From: =?iso-8859-1?Q?Eli=E9zer_Madeira_de_Campos?= To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.001 required=5 tests=[AWL=0.001] X-Spam-Score: 0.001 X-Spam-Level: X-Archive-Number: 200511/18 X-Sequence-Number: 14116 Hello everyone: I'm currently working to migrate a database from PostgreSQL 7.3 to = 8.0.4. I have found the two issues below: =20 1) Timestamp before 1914.=20 When I execute the query by java statement no problem occurs, but = when I execute the query=20 by java preparedstatement this is what happens: PreparedStatement pst =3D con.prepareStatement("insert into teste = values (?, ?, ?)"); pst.setObject(1, new Integer(1)); pst.setObject(2, "TESTE"); Calendar c =3D new GregorianCalendar(1913, 0, 1, 0, 0, 0); Timestamp t =3D new Timestamp(c.getTimeInMillis()); pst.setTimestamp(3, t); pst.executeUpdate(); The date stored in database is actually 1912-12-31 23:53:12.0 = (however it should have stored 1913-01-01. =20 I have already debugged the Postgres-8.0 (build 313) driver and it = seems to send the correct date to database. =20 This problem occurs both with Windows and Linux versions of PostgreSQL = 8. There is a small difference in the actual date stored, but in both = systems it is not the date I'm trying to store. =20 2) Another problem is with functions like date_trunc and date_part = that use a timestamp parameter. The problem ocurrs only with the java preparedstatment. =20 Calendar c =3D new GregorianCalendar(); Timestamp ts =3D new Timestamp(c.getTimeInMillis()); pst =3D con.prepareStatement("select date_trunc('day', TIMESTAMP = ?)"); pst.setObject(1, ts); rs =3D pst.executeQuery(); below the printstacktrace: =20 Exception in thread "main" java.sql.SQLException: ERROR: syntax = error at or near "$1" at = org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecut= orImpl.java:1471) at = org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl= .java:1256) at = org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:1= 75) at = org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statemen= t.java:392) at = org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc= 2Statement.java:330) at = org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Sta= tement.java:240) at teste.Teste3.main(Teste3.java:54) This behaviour is exactly the same both in Windows and Linux. Any ideas? Eli=E9zer M de Campos/Fernando Rubbo