# ORA-01000: maximum open cursors exceeded

**Code:** `ORA-01000` · **Category:** SQL · **Seen on:** Oracle, Java

A session opened more cursors than `OPEN_CURSORS` allows, almost always because statements/result sets aren't closed.

## Meaning

It is nearly always an application leak: close `ResultSet`, `Statement` and `PreparedStatement` (try-with-resources), avoid creating statements in loops without closing, and fix ref cursors. Raise `OPEN_CURSORS` only after fixing the leak. Check `v$open_cursor`.

## Common causes

- Statements/ResultSets not closed
- Prepared statements created in a loop
- Ref cursors never closed
- `OPEN_CURSORS` too low
- Connection pool caching too many statements

## Quick fix

1. Close resources (try-with-resources / finally)
2. Find leaks: `SELECT sql_text, COUNT(*) FROM v$open_cursor GROUP BY sql_text ORDER BY 2 DESC`
3. Then raise `OPEN_CURSORS`

## Detailed fix by platform

### SQL

1. `SELECT a.value, s.sid, s.username FROM v$sesstat a, v$statname b, v$session s WHERE a.statistic#=b.statistic# AND s.sid=a.sid AND b.name='opened cursors current' ORDER BY a.value DESC;`

## How to diagnose

1. **Open cursors** — Growing?
2. **Close** — Missing?
3. **OPEN_CURSORS** — Value?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/sql/ora-01000-maximum-open-cursors-exceeded)
