(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          [EMAIL PROTECTED]

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) {}
        }
    }

}





---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly

Reply via email to