Hi all,
I already reported this directly to Peter Mount but since I have since
joined this list I thought I should make it a more wide-spread report.
The issue is that if you use getDate() on a field that is a timestamp type
then you will get an SQLException that wraps a NumberFormatException. While
this behavior is arguably correct, our main problem is that PG 7.0 did not
have this problem and I think it would be nice if 7.1 didn't break our old
code.
To that end, the following is as replacement to the getDate() method it
ResultSet and fixes the problem, at least for me. I think it is harmless to
provide the ability to get a date from a timestamp. If you do not agree to
add this to the JDBC driver please let me know ASAP so that I can begin
fixing our code in preparation for 7.1.
/**
* Get the value of a column in the given row as a java.sql.Date
* object. This handles both <code>Timestamp</code> and <code>
* Date</code> fields, truncating the time portion in the case of a
* Timestamp.
*
* @param columnIndex the first column is 1, the second is 2...
* @return the column value; null if SQL NULL
* @exception SQLException if a database access error occurs
*/
public java.sql.Date getDate( int columnIndex ) throws SQLException
{
String s = getString( columnIndex );
if( s == null )
return null;
java.sql.Date date = null;
try {
date = java.sql.Date.valueOf( s );
} catch( NumberFormatException e ) {
date = new java.sql.Date( getTimestamp( columnIndex ).getTime() );
}
return date;
}
Best regards,
--Rainer