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 3E29B52B46 for ; Fri, 19 Aug 2005 16:18:44 -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 12669-06 for ; Fri, 19 Aug 2005 19:18:40 +0000 (GMT) Received: from mail.liquidcore.com (mail.liquidcore.com [70.151.60.104]) by svr1.postgresql.org (Postfix) with ESMTP id 0890A52B6A for ; Fri, 19 Aug 2005 16:18:38 -0300 (ADT) Received: (from root@localhost) by mail.liquidcore.com (8.13.1/8.12.10) id j7JJIl76019711 for pgsql-jdbc@postgresql.org; Fri, 19 Aug 2005 14:18:47 -0500 Received: from [192.168.0.81] (ppasalalinux.nqadmin.com [192.168.0.81]) by mail.liquidcore.com (8.13.1/8.12.10) with ESMTP id j7JJIlTO019683 for ; Fri, 19 Aug 2005 14:18:47 -0500 Message-ID: <4306322D.7090505@nqadmin.com> Date: Fri, 19 Aug 2005 14:25:33 -0500 From: Prasanth Reply-To: dbadmin@nqadmin.com User-Agent: Mozilla Thunderbird 1.0.6-1.1.fc3 (X11/20050720) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Bad value for type date 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, hits=0 required=5 tests=[none] X-Spam-Level: X-Archive-Number: 200508/150 X-Sequence-Number: 13719 Hi, 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? String sql = "SELECT * FROM table where = 9159;"; JdbcRowSetImpl rs = new JdbcRowSetImpl(connection); rs.setCommand(sql); rs.execute(); rs.next(); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MONTH, 1); calendar.set(Calendar.DATE, 1); calendar.set(Calendar.YEAR, 10000); Date date = new Date(calendar.getTimeInMillis()); System.out.println(date); rs.updateDate("end_date", date); rs.updateRow(); System.out.println("Date: " + rs.getDate("end_date") + " " + rs.getString("plan_id") +" "+ rs.getDate("start_date")); This causes org.postgresql.util.PSQLException: Bad value for type date : at org.postgresql.jdbc2.TimestampUtils.loadCalendar(TimestampUtils.java:155) at org.postgresql.jdbc2.TimestampUtils.toDate(TimestampUtils.java:245) at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getDate(AbstractJdbc2ResultSet.java:2075) at com.sun.rowset.JdbcRowSetImpl.getDate(JdbcRowSetImpl.java:1087) at com.sun.rowset.JdbcRowSetImpl.getDate(JdbcRowSetImpl.java:1403) at PostgresDate.main(PostgresDate.java:30) Caused by: java.lang.NumberFormatException at org.postgresql.jdbc2.TimestampUtils.number(TimestampUtils.java:407) at org.postgresql.jdbc2.TimestampUtils.loadCalendar(TimestampUtils.java:47) ... 5 more When I query the database using psql Below is what is in the database | 2000-01-01 | 10000-02-01 | 9159 | So it did update the database. After running this I ran the following program. String sql = "SELECT * FROM accounting_periods where plan_id = 9159;"; JdbcRowSetImpl rs = new JdbcRowSetImpl(connection); rs.setCommand(sql); rs.execute(); rs.next(); System.out.println("Date: " + rs.getDate("end_date") + " " + rs.getString("id") +" "+ rs.getDate("start_date")); Output: Date: Thanks, -Prasanth.