Subject | null pointer exception when calling getLong() |
---|---|
Author | Fred Gordon |
Post date | 2004-08-07T14:16:45Z |
I have noticed that if I use the ResultSet.getLong(columnIndex) and the
database column is SQL null I am getting a null pointer exception. I
tested this with other drivers/database and I didn't get this exception.
From what I have read in the API, ResultSet.getLong(columnIndex) should:
*Returns:*
the column value; if the value is SQL |NULL|, the value returned is |0|
To fix it I did this:
In the class org.firebirdsql.jdbc.field.FBBigDecimalField.java I changed
this:
public long getLong() throws SQLException {
return getBigDecimal().longValue();
}
to this:
public long getLong() throws SQLException {
BigDecimal bd = getBigDecimal();
if (bd == null)
return 0;
return bd.longValue();
}
This is from a cvs checkout from today (08/06/2004).
-Fred.
database column is SQL null I am getting a null pointer exception. I
tested this with other drivers/database and I didn't get this exception.
From what I have read in the API, ResultSet.getLong(columnIndex) should:
*Returns:*
the column value; if the value is SQL |NULL|, the value returned is |0|
To fix it I did this:
In the class org.firebirdsql.jdbc.field.FBBigDecimalField.java I changed
this:
public long getLong() throws SQLException {
return getBigDecimal().longValue();
}
to this:
public long getLong() throws SQLException {
BigDecimal bd = getBigDecimal();
if (bd == null)
return 0;
return bd.longValue();
}
This is from a cvs checkout from today (08/06/2004).
-Fred.