X-Original-To: pgsql-jdbc@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3CFDA474E5C for ; Fri, 7 Feb 2003 21:16:14 -0500 (EST) Received: from mail.xythos.com (ip-216-36-77-241.dsl.sjc.megapath.net [216.36.77.241]) by postgresql.org (Postfix) with ESMTP id 8E432474E4F for ; Fri, 7 Feb 2003 21:16:13 -0500 (EST) Received: from ravms by mail.xythos.com with mail-ok (Exim 3.36 #3) id 18hKXQ-0002gW-00; Sat, 08 Feb 2003 02:16:16 +0000 Received: from ip-216-36-77-241.dsl.sjc.megapath.net ([216.36.77.241] helo=xythos.com) by mail.xythos.com with asmtp (Exim 3.36 #3) id 18hKXQ-0002gL-00; Sat, 08 Feb 2003 02:16:16 +0000 Message-ID: <3E440D85.6040201@xythos.com> Date: Fri, 07 Feb 2003 11:48:21 -0800 From: Barry Lind User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Peter Katzmann Cc: PostgreSQL JDBC Subject: Re: Timestamp problems References: <3E4266AC.4060907@thiesen.com> <3E429520.904@xythos.com> <3E43B5DC.60901@thiesen.com> In-Reply-To: <3E43B5DC.60901@thiesen.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed X-Envelope-To: p.katzmann@thiesen.com, pgsql-jdbc@postgresql.org Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/156 X-Sequence-Number: 6327 Peter, I looked at the sample program you sent (thanks for the test program, it=20 makes it much easier to understand). From what I can tell the driver is=20 working correctly. The data type of the column datum that you create is 'date'. Since a=20 'date' does not store any time information the rest of the behavior you=20 see is related to this fact. So why are you using setTimestamp/getTimestamp when the data type is=20 date? You should be using setDate/getDate. If I either change the data type to 'timestamp' in your program, or use=20 getDate/setDate with the 'date' data type everything works as I would=20 expect. The fact that you are mixing dates and timestamps I think is causing=20 your problems. However I believe the driver is functioning correctly=20 givin what your code is actually doing. thanks, --Barry Peter Katzmann wrote: > Hello Attached is the example with the same error and here is a small=20 > database log: > 2003-02-07 14:32:32 [17354] LOG: connection received:=20 > host=3D192.168.2.11 port=3D33900 > 2003-02-07 14:32:32 [17354] LOG: connection authorized: user=3Dpostgres= =20 > database=3Dachievo > 2003-02-07 14:32:32 [17354] LOG: query: set datestyle to 'ISO'; select= =20 > version(), case when pg_encoding_to_char(1) =3D 'SQL_ASCII' then 'UNKNOWN= '=20 > else getdatabaseencoding() end; > 2003-02-07 14:32:32 [17354] LOG: query: create temp table tmp ( datum= =20 > date, idx int) > 2003-02-07 14:32:32 [17354] LOG: query: insert into tmp=20 > Values('2003-02-07 13:32:31.668000000+00', 0) > 2003-02-07 14:32:32 [17354] LOG: query: insert into tmp=20 > Values('2003-02-07 13:32:31.913000000+00', 1) > 2003-02-07 14:32:32 [17354] LOG: query: insert into tmp=20 > Values('2003-02-07 13:32:31.916000000+00', 2) > 2003-02-07 14:32:32 [17354] LOG: query: insert into tmp=20 > Values('2003-02-07 13:32:31.919000000+00', 3) > 2003-02-07 14:32:32 [17354] LOG: query: insert into tmp=20 > Values('2003-02-07 13:32:31.921000000+00', 4) > 2003-02-07 14:32:32 [17354] LOG: query: insert into tmp=20 > Values('2003-02-07 13:32:31.923000000+00', 5) > 2003-02-07 14:32:32 [17354] LOG: query: insert into tmp=20 > Values('2003-02-07 13:32:31.926000000+00', 6) > 2003-02-07 14:32:32 [17354] LOG: query: insert into tmp=20 > Values('2003-02-07 13:32:31.928000000+00', 7) > 2003-02-07 14:32:32 [17354] LOG: query: insert into tmp=20 > Values('2003-02-07 13:32:31.939000000+00', 8) > 2003-02-07 14:32:32 [17354] LOG: query: insert into tmp=20 > Values('2003-02-07 13:32:31.941000000+00', 9) > 2003-02-07 14:32:32 [17354] LOG: query: select * from tmp > 2003-02-07 14:32:32 [17354] LOG: query: update tmp set=20 > datum=3D'2003-02-06 23:00:00.000000000+00' where idx=3D0 > 2003-02-07 14:32:32 [17354] LOG: query: update tmp set=20 > datum=3D'2003-02-06 23:00:00.000000000+00' where idx=3D1 > 2003-02-07 14:32:32 [17354] LOG: query: update tmp set=20 > datum=3D'2003-02-06 23:00:00.000000000+00' where idx=3D2 > 2003-02-07 14:32:32 [17354] LOG: query: update tmp set=20 > datum=3D'2003-02-06 23:00:00.000000000+00' where idx=3D3 > 2003-02-07 14:32:32 [17354] LOG: query: update tmp set=20 > datum=3D'2003-02-06 23:00:00.000000000+00' where idx=3D4 > 2003-02-07 14:32:32 [17354] LOG: query: update tmp set=20 > datum=3D'2003-02-06 23:00:00.000000000+00' where idx=3D5 > 2003-02-07 14:32:32 [17354] LOG: query: update tmp set=20 > datum=3D'2003-02-06 23:00:00.000000000+00' where idx=3D6 > 2003-02-07 14:32:32 [17354] LOG: query: update tmp set=20 > datum=3D'2003-02-06 23:00:00.000000000+00' where idx=3D7 > 2003-02-07 14:32:32 [17354] LOG: query: update tmp set=20 > datum=3D'2003-02-06 23:00:00.000000000+00' where idx=3D8 > 2003-02-07 14:32:32 [17354] LOG: query: update tmp set=20 > datum=3D'2003-02-06 23:00:00.000000000+00' where idx=3D9 >=20 >=20 > Barry Lind wrote: >=20 >> Peter, >> >> When you say you tried with the current version what do you mean?=20 >> Specifically have you tried the latest 7.3 build from=20 >> jdbc.postgresql.org? There were some recent bug fixes in this area=20 >> that I think may fix your problem. >> >> If the current code still has this problem, can you submit a test case= =20 >> that we can compile and run that demonstrates the problem? >> >> thanks, >> --Barry >> >> >> Peter Katzmann wrote: >> >>> High, >>> i' currently working with hibernate. They represent Calendar types as >>> timestamps. During prepareStatement and setTimestamp the data=20 >>> generated for >>> the query has a modified date. The date is something original: >>> >>> >>> insert into hours ( entrydate, activitydate, remark, time, userid,=20 >>> checked, >>> phaseid, activityid, zkub, id ) values '2003-02-06=20 >>> 11:11:29.338000000+00', >>> '2003-02-06 11:11:29.338000000+00', '=F6f=F6lsdajkl=F6', 120, 'pk1057',= =20 >>> 'f', null, >>> null, null, 12747 ) >>> >>> >>> And this will be aftter the data was read back, the checked flag=20 >>> changed and >>> wrote back >>> >>> update hours set entrydate =3D '2003-02-05 23:00:00.000000000+00',=20 >>> activitydate >>> =3D '2003-02-05 23:00:00.000000000+00', remark =3D '=F6f=F6lsdajkl=F6',= time =3D=20 >>> 120, >>> userid =3D 'pk1057', checked =3D 't', phaseid =3D 5, activityid =3D 3, = zkub =3D=20 >>> ' ' >>> where id =3D 12747 >>> >>> First occured the problem with postgres 7.2 so i updated to a current= =20 >>> version, >>> but no go either. >>> >>> >>> peter >>> >>> >>> >>> ---------------------------(end of broadcast)--------------------------- >>> TIP 5: Have you checked our extensive FAQ? >>> >>> http://www.postgresql.org/users-lounge/docs/faq.html >>> >>> >> >> >> >> >> ---------------------------(end of broadcast)--------------------------- >> TIP 2: you can get off all lists at once with the unregister command >> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) >> >=20 >=20 >=20 > ------------------------------------------------------------------------ >=20 > /* > * TryOut.java > * > * Created on 7. Februar 2003, 13:36 > */ >=20 > import java.sql.*; >=20 >=20 > /** > * > * @author root > */ > public class TryOut { > private java.sql.Connection dbConnection =3D null; >=20=20=20 > /** Die URL zur Datenbank */ > private String dbURL =3D null; > /** Der Datenbank-Banutzer */ > private String dbUser =3D null; > /** Das Password des Datenbank-Benutzers */ > private String dbPasswd =3D null; > /*********************** > * simple table of the form > * > * > * /** Creates a new instance of TryOut */ > public TryOut() { > } >=20=20=20 > /** > * @param args the command line arguments > */ > public static void main(String[] args) { > TryOut tr =3D new TryOut(); > tr.doIt(); > } >=20=20=20 > private void doIt() { > try { > Class.forName("org.postgresql.Driver"); > dbConnect("jdbc:postgresql://kontor.thiesen.de:5432/achievo?charSet= =3DISO-8859-15", "postgres", "postgres"); > Statement state =3D dbConnection.createStatement(); > state.execute("create temp table tmp ( datum date, idx int)"); > PreparedStatement st1 =3D dbConnection.prepareStatement("insert int= o tmp Values(?, ?)"); > PreparedStatement st2 =3D dbConnection.prepareStatement("update tmp= set datum=3D? where idx=3D?"); >=20=20=20=20=20=20=20 > for (int i =3D 0; i < 10; i++) { > st1.setInt(2, i); > st1.setTimestamp(1,new Timestamp(new java.util.Date().getTime())); > st1.execute(); > } > ResultSet rs =3D state.executeQuery("select * from tmp"); > for (int i =3D 0; i < 10; i++) { > rs.absolute(i+1); > st2.setTimestamp(1, new Timestamp(rs.getDate(1).getTime())); > st2.setInt(2, i); > st2.execute(); > } > dbConnection.close(); > } catch (Exception e) { > e.printStackTrace(); > } > } >=20=20=20 > /* Oeffnet die Datenbankverbindung > * > * @param dbUrl die JDBC-RessourcenURL > * @param dbUser dbUser > * @param dbPasswd > * > * @exception SQLException noch Fragen? > */ >=20=20=20 >=20=20=20 > public void dbConnect(String dbURL, String dbUsr, String dbPwd) { > this.dbURL =3D dbURL; > this.dbUser =3D dbUsr; > this.dbPasswd =3D dbPwd; >=20=20=20=20=20 > dbConnect(); > } >=20=20=20 > /** > * Oeffnet die Datenbankverbindung > * > * @param dbUrl die JDBC-RessourcenURL > * @param dbUser dbUser > * @param dbPasswd > * > * @exception SQLException noch Fragen? > */ > private void dbConnect() { > /* Verbindung zur Datenbank aufbauen */ > // getMainSession().getDebug().message(this, "DriverManager.getConne= ction() "+dbURL+" "+dbUser+" ********"); > System.out.println( "DriverManager.getConnection() "+dbURL+" "+dbUser= +" ********"); > try { > this.dbConnection =3D DriverManager.getConnection(dbURL, dbUser, db= Passwd); > } catch (SQLException se) { > se.printStackTrace(); > } >=20=20=20=20=20 > try { > DatabaseMetaData dmd =3D dbConnection.getMetaData(); > String dbi =3D new String(); >=20=20=20=20=20=20=20 > dbi =3D dbi.concat("--- database: "+dmd.getDatabaseProdu= ctName()+"\n"); > dbi =3D dbi.concat("--- databse version: "+dmd.getDatabaseProdu= ctVersion()+"\n"); > dbi =3D dbi.concat("--- JDBC driver name: "+dmd.getDriverName()+= "\n"); > dbi =3D dbi.concat("--- JDBC driver version: "+dmd.getDriverVersion= ()); > //getMainSession().getDebug().message(this, "Database Info:\n"+dbi); > System.out.println( "Database Info:\n"+dbi); > } catch (SQLException se) { > se.printStackTrace(); > } >=20=20=20=20=20 > } >=20=20=20 > }