closeOnCompletion
Dave Cramer
davecramer at gmail.com
Wed Feb 17 17:34:41 UTC 2021
On Wed, 17 Feb 2021 at 12:13, Filipe Silva <filipe.silva at oracle.com> wrote:
> On 17/02/21 10:53, Dave Cramer wrote:
> > Interesting situation.
> >
> > If we have an open statement with open resultsets and call
> > closeOnCompletion and then execute the statement a second time the
> > statement will throw an already closed exception since the spec says that
> > executing a statement a second time closes any open resultsets. Closing
> > said resultsets ends up closing the statement.
> >
> > I'm just confirming that this is the intended behaviour. Seems about
> right
> > since if you set closeOnCompletion you would not expect to re-use the
> > statement.
> >
> > Dave Cramer
> No, I don't think it is supposed to work like this. "Completion" means
> that the user is done with the ResultSet(s) and explicitely calls
> close() on it/them.
>
> Successive executions do close previously opened ResultSets but closing
> those ResultSets implicitely (by re-executing) do not close the
> Statement. The documentation makes it clear when it says "a call to
> |closeOnCompletion| does effect both the *subsequent execution of
> statements*, (...)". There would be no "subsequent execution of
> statements" if the behavior was the one you described.
>
Well interestingly I'm told that the Oracle driver does close the statement
on subsequent execution.
Either way I'm not sure I agree with the inference. Now we have to debate
the word execution. Is calling the method an execution or is completing the
call an execution ?
Dave Cramer
>
>
More information about the jdbc-spec-discuss
mailing list