date problem with postgres JDBC 7.1 driver

Поиск
Список
Период
Сортировка
Искать

date problem with postgres JDBC 7.1 driver

От:
David Brownlee <abs@formula1.com>
Дата:
	(I'm not subscribed to the list, please cc directly in replies)

	We have an application using the jdbc driver from postgres
	7.0.x, compiled under java1. We have migrated the database
	to 7.1.2, and would like to update the jdbc driver to match.

	The application selects() a timestamp as a date, which
	works fine under the earlier JDBC, and other databases such
	as MS SQLserver, but fails with a NumberFormatException under
	the new driver.

	Can anyone confirm if this is correct JDBC behaviour (in which
	case I have to persuade our developers to update their code :)

	Sample code appended.

	Thanks


-- 
		David/absolute		abs@formula1.com

import java.math.*;
import java.sql.*;
import java.util.*;

/*
CREATE TABLE Race
( RaceId        int           NOT NULL,
  RaceDate      timestamp     NOT NULL,
  CONSTRAINT PK_Race PRIMARY KEY (RaceId)
);

INSERT INTO Race VALUES (195001, '1950-05-13');

Output after running with earlier class files:
Race Id = 195001
Race Date as Timestamp = 1950-05-13 00:00:00.0
Race Date as Date = 1950-05-13


Output after running with newest class files:
Race Id = 195001
Race Date as Timestamp = 1950-05-13 00:00:00.0
java.lang.NumberFormatException: 13 00:00:00+01
        at java.lang.Integer.parseInt(Unknown Source)
        at java.lang.Integer.parseInt(Unknown Source)
        at java.sql.Date.valueOf(Unknown Source)
        at org.postgresql.jdbc2.ResultSet.getDate(ResultSet.java:427)
        at org.postgresql.jdbc2.ResultSet.getDate(ResultSet.java:665)
        at Remote.main(Remote.java:33)

*/

public class Remote
{
    public static void main(String args[])
    {
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;

        try
        {
            Class.forName("org.postgresql.Driver");
            conn = DriverManager.getConnection("jdbc:postgresql://wopr:5432/f1archive", "tom", "");
            ps = conn.prepareStatement("SELECT RaceId, RaceDate FROM Race WHERE RaceId = 195001;");
            rs = ps.executeQuery();
            while (rs.next())
            {
                System.out.println("Race Id = " + rs.getInt("RaceId"));
                System.out.println("Race Date as Timestamp = " + rs.getTimestamp("RaceDate"));
                System.out.println("Race Date as Date = " + rs.getDate("RaceDate"));
            }
        }

        catch(Exception e)
        {
            e.printStackTrace();
        }
        finally
        {
            try
            {
                if (rs != null)
                    rs.close();
                if (ps != null)
                    ps.close();
                if (conn != null)
                    conn.close();
            }
            catch(SQLException e) {}
        }
    }

}




Re: date problem with postgres JDBC 7.1 driver

От:
Barry Lind <barry@xythos.com>
Дата:
David,

This is a problem in the driver.  I believe it is fixed in current 
sources.  Can you download the latest development build from 
jdbc.postgresql.org and see if that works for you?

thanks,
--Barry

David Brownlee wrote:

> 	(I'm not subscribed to the list, please cc directly in replies)
> 
> 	We have an application using the jdbc driver from postgres
> 	7.0.x, compiled under java1. We have migrated the database
> 	to 7.1.2, and would like to update the jdbc driver to match.
> 
> 	The application selects() a timestamp as a date, which
> 	works fine under the earlier JDBC, and other databases such
> 	as MS SQLserver, but fails with a NumberFormatException under
> 	the new driver.
> 
> 	Can anyone confirm if this is correct JDBC behaviour (in which
> 	case I have to persuade our developers to update their code :)
> 
> 	Sample code appended.
> 
> 	Thanks
> 
> 
> 


Re: date problem with postgres JDBC 7.1 driver

От:
David Brownlee <abs@formula1.com>
Дата:
	Sorry for the delay in responding. Can confirm this is fixed in
	7.2dev (2001-12-10).

	Is there an expected release date for the next version yet?

	Thanks

-- 
		David/absolute		abs@formula1.com

On Thu, 11 Oct 2001, Barry Lind wrote:

> David,
>
> This is a problem in the driver.  I believe it is fixed in current
> sources.  Can you download the latest development build from
> jdbc.postgresql.org and see if that works for you?
>
> thanks,
> --Barry
>
> David Brownlee wrote:
>
> > 	(I'm not subscribed to the list, please cc directly in replies)
> >
> > 	We have an application using the jdbc driver from postgres
> > 	7.0.x, compiled under java1. We have migrated the database
> > 	to 7.1.2, and would like to update the jdbc driver to match.
> >
> > 	The application selects() a timestamp as a date, which
> > 	works fine under the earlier JDBC, and other databases such
> > 	as MS SQLserver, but fails with a NumberFormatException under
> > 	the new driver.
> >
> > 	Can anyone confirm if this is correct JDBC behaviour (in which
> > 	case I have to persuade our developers to update their code :)
> >
> > 	Sample code appended.
> >
> > 	Thanks
> >
> >
> >
>
>
>

Re: date problem with postgres JDBC 7.1 driver

От:
Rene Pijlman <rene@lab.applinet.nl>
Дата:
On Wed, 19 Dec 2001 12:14:39 +0000 (GMT), you wrote:
>Can confirm this is fixed in 7.2dev (2001-12-10).
>Is there an expected release date for the next version yet?

7.2 is currently in the final beta stage, so it should be
released Real Soon Now.

Regards,
René Pijlman 
FAQ