Bug #4689 ResultSet.wasNull does not work for primatives if a previous null was returned.
Submitted: 22 Jul 2004 6:01 Modified: 23 Jul 2004 3:42
Reporter: Chris Wood Email Updates:
Status: Closed Impact on me:
Category:Connector / J Severity:S2 (Serious)
Version:3.1.3-beta OS:
Assigned to: Mark Matthews CPU Architecture:Any

[22 Jul 2004 6:01] Chris Wood
The wasNull method incorrectly returns true in some cases when the returned value was not in fact null.

This happens when a null value is returned, then another method is invoked to return a primative value (ie: getInt). After this second call wasNull incorrectly returns true.

How to repeat:
1. Create a result set with embedded nulls.
2. call a getX method to return one of the null columns.
3. The response from wasNull returns true.
4. call a getInt method to return a non-null int column.
5. wasNull still returns true.

Suggested fix:
I've fixed this bug, the changed ResultSet implementation is attached.
[22 Jul 2004 6:02] Chris Wood
Fixed ResultSet

Attachment: ResultSet.java (text/plain), 190.97 KiB.

[22 Jul 2004 6:05] Chris Wood
Note that I've performed some cleanup for null checking, the checking of null values now occours in the checkNull method. 

The three methods that convert dates to strings also manipulate the status of the last null value boolean, they have also been modified to ensure that they explicitly set the null flag no matter how they return.
[22 Jul 2004 19:50] Dean Ellis
I cannot repeat this with the nightly shapshot mysql-connector-java-3.1-nightly-20040722-bin.jar; it returns correctly.
[23 Jul 2004 3:13] Chris Wood
The bug only occours when using a prepared statement.

I've attached a test case which demonstrates the issue.
[23 Jul 2004 3:14] Chris Wood
Test case that demonstrates the issue.

Attachment: NullNumbersTest.java (text/plain), 3.31 KiB.

[23 Jul 2004 3:42] Mark Matthews
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at