ORA-01000: Oracle maximum open cursors exceeded in Spring Boot

Published
Updated

I have noticed this error on occasion if a large number of queries were executed in a short time. Even though connections were being managed with a jdbcTemplate, the cursors were not getting closed. This issue was not related to the application code structure, transaction management, nor anything else relating to the connection, yet the statements continually failed to close properly.

Solution

There is a bug in older versions of Oracle OJDBC libraries which does not play nice with Spring’s JDBC connection management libraries. To fix this, update your OJDBC jar to the latest version.

Latest version of the Oracle OJDBC8 Jar:

<dependency>
    <groupId>com.oracle.ojdbc</groupId>
    <artifactId>ojdbc8</artifactId>
    <version>19.3.0.0</version>
</dependency>

Latest version of the Oracle OJDBC10 Jar:

<dependency>
    <groupId>com.oracle.ojdbc</groupId>
    <artifactId>ojdbc10</artifactId>
    <version>19.3.0.0</version>
</dependency>

You can also find these JDBC drivers available for download from Oracle