Filipe Silva filipe.silva at
Wed Feb 17 17:13:16 UTC 2021

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.

Filipe Silva


Oracle <>
Filipe Silva, Senior Software Developer
Mobile: +351.91.009.2110
MySQL Middleware and Clients
Oracle Portugal, Lagoas Park, Edifício N.º 8, 2740-244 Porto Salvo

More information about the jdbc-spec-discuss mailing list