[1.7.x] Prevented a crash in the cursor wrappers on Oracle.

Fixed #22483 (again).

Backport of 0f85103e from master
[1.7.x] Ignored repeated calls to connection.close().

Backport of d4cc59ef from master