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 A956552897 for ; Sat, 20 Aug 2005 10:11:08 -0300 (ADT) 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 50729-01 for ; Sat, 20 Aug 2005 13:11:00 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id C66DE52DAD for ; Sat, 20 Aug 2005 10:10:58 -0300 (ADT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=[192.168.0.20]) by yass.opencloud.co.nz with asmtp (TLS-1.0:DHE_RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1E6T7l-0001p0-Ec; Sun, 21 Aug 2005 01:11:02 +1200 Message-ID: <43072BE0.9000306@opencloud.com> Date: Sun, 21 Aug 2005 01:10:56 +1200 From: Oliver Jowett User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: dbadmin@nqadmin.com Cc: pgsql-jdbc@postgresql.org Subject: Re: Bad value for type date References: <4306322D.7090505@nqadmin.com> In-Reply-To: <4306322D.7090505@nqadmin.com> X-Enigmail-Version: 0.90.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/mixed; boundary="------------060604020105000208030802" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.008 required=5 tests=[AWL=0.008] X-Spam-Level: X-Archive-Number: 200508/154 X-Sequence-Number: 13723 This is a multi-part message in MIME format. --------------060604020105000208030802 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Prasanth wrote: > Below is a small program to test the JDBC date issue I have having. > > I am able to set the date "2/1/10000". But it fails to retrieve it. > > If it is invalid date then it should not even update the database right? I can't reproduce this; the attached testcase produces this against my 8.0 install: Inserting date: 10000-02-01 AD +1300 Got date: 10000-02-01 AD +1300 Got date: 10000-02-01 AD +1300 I get this using both the -310 driver and a build from CVS HEAD. You'll need to give us a compilable testcase that shows the problem to take this any further. The code you provided originally doesn't compile out-of-the-box, is missing schema information, and has a syntactically incorrect query.. It'd also help if you can reproduce your problem without involving a RowSet implementation. -O --------------060604020105000208030802 Content-Type: text/plain; name="TestDate2.java" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="TestDate2.java" import java.sql.*; import java.util.Calendar; public class TestDate2 { public static void main(String[] args) throws Exception { Class.forName("org.postgresql.Driver"); Connection conn = DriverManager.getConnection(args[0]); Statement stmt = conn.createStatement(); try { stmt.executeUpdate("DROP TABLE testdate2"); } catch (SQLException e) {} stmt.executeUpdate("CREATE TABLE testdate2(d date)"); stmt.executeUpdate("INSERT INTO testdate2(d) VALUES ('10000/02/01')"); PreparedStatement ps = conn.prepareStatement("INSERT INTO testdate2(d) VALUES (?)"); Calendar c = Calendar.getInstance(); c.set(Calendar.MONTH, 1); c.set(Calendar.DATE, 1); c.set(Calendar.YEAR, 10000); Date d = new Date(c.getTimeInMillis()); java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd G Z"); System.out.println("Inserting date: " + sdf.format(d)); ps.setDate(1, d); ps.executeUpdate(); ResultSet rs = stmt.executeQuery("SELECT d FROM testdate2"); while (rs.next()) { d = rs.getDate(1); System.out.println("Got date: " + sdf.format(d)); } rs.close(); stmt.close(); conn.close(); } } --------------060604020105000208030802--