Skip site navigation (1) Skip section navigation (2)

Re: Bad value for type date

From: "Prasanth" <dbadmin(at)nqadmin(dot)com>
To: "Oliver Jowett" <oliver(at)opencloud(dot)com>
Cc: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Bad value for type date
Date: 2005-08-20 16:16:37
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc

Below if the code with result set to reproduce the problem.


import java.sql.*;
import java.util.Calendar;

public class TestDate2 {
    public static void main(String[] args) throws Exception {

        Connection conn = DriverManager.getConnection(args[0]);
        Statement stmt = conn.createStatement(

        try {
            stmt.executeUpdate("DROP TABLE testdate2");
        } catch (SQLException e) {}

        stmt.executeUpdate("CREATE TABLE testdate2(id int4 primary key, d
        stmt.executeUpdate("INSERT INTO testdate2(id, 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());

    ResultSet rs = stmt.executeQuery("SELECT * FROM testdate2");
	while ( {
		   rs.updateDate("d", d);
           d = rs.getDate("d");
           System.out.println("Got date: " + d);


-----Original Message-----
From: Oliver Jowett [mailto:oliver(at)opencloud(dot)com]
Sent: Saturday, August 20, 2005 8:11 AM
To: dbadmin(at)nqadmin(dot)com
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: [JDBC] Bad value for type date

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.


In response to


pgsql-jdbc by date

Next:From: Oliver JowettDate: 2005-08-20 21:40:57
Subject: Re: Bad value for type date
Previous:From: Oliver JowettDate: 2005-08-20 13:10:56
Subject: Re: Bad value for type date

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group