Issue Details (XML | Word | Printable)

Key: JDBC-350
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Mark Rotteveel
Reporter: Mark Rotteveel
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Jaybird JCA/JDBC Driver

Processing and closing the ResultSet from callable statement and then using the getters throws NullPointerException

Created: 27/Apr/14 02:53 PM   Updated: 22/Jan/15 12:29 PM
Component/s: JDBC driver
Affects Version/s: Jaybird 2.1.6, Jaybird 2.2, Jaybird 2.2.1, Jaybird 2.2.2, Jaybird 2.2.3, Jaybird 2.2.4, Jaybird 2.2.5
Fix Version/s: Jaybird 2.2.6, Jaybird 3.0.0

File Attachments: 1. Java Source File SO20140427.java (2 kB)

Issue Links:
Relate


 Description  « Hide
When an executable stored procedure is processed by first reading the ResultSet and then using the getters on CallableStatement (as for example Spring SimpleJdbcCall does), then the getter will throw a NullPointerException.

See the attached file and http://stackoverflow.com/questions/23238260/simplejdbccall-nullpointerexception-on-firebird-db for an example of this problem.

See also JDBC-297 and JDBC-229

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Lukas Eder added a comment - 18/Nov/14 11:07 AM
While implementing routine support in jOOQ, I've run into this issue as well. This would be a very helpful fix.

Mark Rotteveel added a comment - 23/Dec/14 03:27 PM
Made two changes:
1) the ResultSet.getRow` method now checks if the result set is still open, otherwise it throws an SQLException. This fixes the NPE thrown.
2) if the CallableStatement concerns an executable procedure (== singleton result), it creates an extra ResultSet with the returned row; this extra ResultSet is used for the accessors of CallableStatement.

For selectable procedures everything continues to work as is, except now trying to use an accessor after processing the result set will not produce a NullPointerException, but an SQLException that the result is closed.

NOTE Being able to obtain a ResultSet for an executable procedure, and use the accessors for a selectable procedure is actually invalid behavior, but for backwards compatibility we leave that as it is for now (might change in JDBC-297).