prestodb/presto · error · SQLException
Connection is closed
Error message
Connection is closed
What it means
In connection(), after the statement's connection reference is found non-null, connection.isClosed() is checked: if the owning PrestoConnection has been closed this SQLException is thrown. It means the statement is being used after its parent connection was closed, so all further statement operations fail.
Source
Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoStatement.java:660
}
}
}
protected final void checkOpen()
throws SQLException
{
connection();
}
protected final PrestoConnection connection()
throws SQLException
{
PrestoConnection connection = this.connection.get();
if (connection == null) {
throw new SQLException("Statement is closed");
}
if (connection.isClosed()) {
throw new SQLException("Connection is closed");
}
return connection;
}
private void closeResultSet()
throws SQLException
{
ResultSet resultSet = currentResult.getAndSet(null);
if (resultSet != null) {
resultSet.close();
}
}
private static boolean validFetchDirection(int direction)
{
return (direction == ResultSet.FETCH_FORWARD) ||
(direction == ResultSet.FETCH_REVERSE) ||
(direction == ResultSet.FETCH_UNKNOWN);View on GitHub (pinned to 55bb57d202)
Solutions
- Keep the Connection open while its Statements/ResultSets are in use
- Obtain a new connection and statement after the old connection was closed
- Fix try-with-resources ordering so the connection outlives statement usage
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoStatement.java:660 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/8e528897f357307e.
Report an issue: GitHub.