[
https://issues.apache.org/jira/browse/NIFI-5070?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16433070#comment-16433070
]
Matt Burgess commented on NIFI-5070:
------------------------------------
The spec doesn't quite say that a SQLException can be thrown when there are no
more rows, rather it implies that next() should first return false, then can
throw an exception (such as other ResultSet methods that require a current row
after next() returns false). I believe DB2 does throw a SQLException instead
of returning false when there are no more rows, I'm not sure if Phoenix does
this or not.
I'd like to avoid calling isClosed() before next() as for a large number of
rows X, we'd be calling it unnecessarily X-1 times. Having said that, if
something happens during processing and the driver/DB closes the result set as
a result of that error, we wouldn't know (with a single try/catch) whether the
result set had finished or had an error somewhere. I think we'd need a
try/catch around the next() only to see if the result set is closed, and an
inner try/catch around everything else, to catch other errors not related to
this behavior. [~markap14] I think you're the one that mentioned not calling
isClosed() every time, any thoughts on this?
> java.sql.SQLException: ERROR 1101 (XCL01): ResultSet is closed
> --------------------------------------------------------------
>
> Key: NIFI-5070
> URL: https://issues.apache.org/jira/browse/NIFI-5070
> Project: Apache NiFi
> Issue Type: Bug
> Components: Core Framework
> Affects Versions: 1.6.0
> Reporter: Gardella Juan Pablo
> Priority: Major
>
> Discovered during NIFI-5049. According [ResultSet.next()
> javadoc|https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSet.html#next%E2%80%93]:
> _When a call to the {{next}} method returns {{false}}, the cursor is
> positioned after the last row. Any invocation of a {{ResultSet}} method which
> requires a current row will result in a {{SQLException}} being thrown. If the
> result set type is {{TYPE_FORWARD_ONLY}}, it is vendor specified whether
> their JDBC driver implementation will return {{false}} or throw an
> {{SQLException}} on a subsequent call to {{next}}._
> With Phoenix Database and QueryDatabaseTable the exception
> {{java.sql.SQLException: ERROR 1101 (XCL01): ResultSet is closed}} is raised.
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)