X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id E8A349DC87E for ; Mon, 16 Jan 2006 18:13:45 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51214-06 for ; Mon, 16 Jan 2006 18:13:44 -0400 (AST) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 96FA59DC86C for ; Mon, 16 Jan 2006 18:13:40 -0400 (AST) Received: from mail.liquidcore.com (mail.liquidcore.com [70.151.60.104]) by svr4.postgresql.org (Postfix) with ESMTP id DD1035AF08A for ; Mon, 16 Jan 2006 22:13:42 +0000 (GMT) Received: (from root@localhost) by mail.liquidcore.com (8.13.1/8.13.1) id k0GMDnJW014664 for pgsql-jdbc@postgresql.org; Mon, 16 Jan 2006 16:13:49 -0600 Received: from [192.168.0.81] (ppasalalinux.nqadmin.com [192.168.0.81]) by mail.liquidcore.com (8.13.1/8.13.1) with ESMTP id k0GMDj1k014578 for ; Mon, 16 Jan 2006 16:13:45 -0600 Message-ID: <43CC1A76.1050402@nqadmin.com> Date: Mon, 16 Jan 2006 16:13:10 -0600 From: Prasanth Reply-To: dbadmin@nqadmin.com User-Agent: Mozilla Thunderbird 1.0.7-1.1.fc3 (X11/20050929) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: getDate after call to updateDate References: <4307C0C5.607@opencloud.com> <4309E8F5.5000507@nqadmin.com> In-Reply-To: <4309E8F5.5000507@nqadmin.com> X-Enigmail-Version: 0.90.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-scanner: Scanned for malicious content X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200601/76 X-Sequence-Number: 14527 But when I use the latest 8.1-404 or even 8.2dev jdbc3 drivers I am observing a strange result. When I update a date in the resultset (say with 12/31/2005) and then call getDate it returns a date which is one day behind the value I have set (returns 12/30/2005). But it updates the database with the right date (12/31/2005). If I re fetch the same row then I can see the right value. I am running 7.4.7 version. Below if the code to reproduce the error. import java.sql.*; import java.util.Calendar; public class PostgresDate { public static void main(String[] args) throws Exception { Class.forName("org.postgresql.Driver"); Connection conn = DriverManager.getConnection("jdbc:postgresql://databases.nqadmin.com:5432/test_server", "postgres", "opelgt"); Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); try { stmt.executeUpdate("DROP TABLE testdate2"); } catch (SQLException e) {} stmt.executeUpdate("CREATE TABLE testdate2(id int4 primary key, d date)"); stmt.executeUpdate("INSERT INTO testdate2(id, d) VALUES (1,'2005-02-10')"); Calendar c = Calendar.getInstance(); c.set(Calendar.MONTH, 1); c.set(Calendar.DATE, 2); c.set(Calendar.YEAR, 2005); Date d = new Date(c.getTimeInMillis()); ResultSet rs = stmt.executeQuery("SELECT * FROM testdate2"); rs.next(); rs.updateDate("d", d); rs.updateRow(); d = rs.getDate("d"); System.out.println("Got date: " + d); rs = stmt.executeQuery("SELECT * FROM testdate2"); rs.next(); d = rs.getDate("d"); System.out.println("Date after refresh: " + d); rs.close(); stmt.close(); conn.close(); } } Thanks, -Prasanth. Prasanth wrote: >Hi Oliver, > >Thank you very much. > >-Prasanth. > >Oliver Jowett wrote: > > >>Prasanth wrote: >> >> >> >> >>>Below if the code with result set to reproduce the problem. >>> >>> >>As a workaround for the -310 driver, call refreshRow() after updateRow() >>and you should be able to retrieve values correctly. >> >>-O >> >>---------------------------(end of broadcast)--------------------------- >>TIP 9: In versions below 8.0, the planner will ignore your desire to >> choose an index scan if your joining column's datatypes do not >> match >> >> >> >> > >---------------------------(end of broadcast)--------------------------- >TIP 2: Don't 'kill -9' the postmaster > > > >