Ignored repeated calls to connection.close().

Forwardport of 9bbb43dd1a from stable/1.7.x
Prevented a crash in the cursor wrappers on Oracle.

Fixed #22483 (again).

Forwardport of 5cd6429620 from stable/1.7.x