apache/seatunnel · warning
JDBC connection close failed.
Error message
JDBC connection close failed.
What it means
SimpleJdbcConnectionProvider.closeConnection() validates then closes the single managed Connection; SQLException on close is logged as a warning and swallowed, and the connection field is always nulled in a finally block. This is deliberate best-effort cleanup: the provider never fails the task on close errors.
Source
Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/connection/SimpleJdbcConnectionProvider.java:132
// caller expectation.
throw new JdbcConnectorException(
JdbcConnectorErrorCode.NO_SUITABLE_DRIVER,
"No suitable driver found for the configured JDBC URL");
}
connection.setAutoCommit(jdbcConfig.isAutoCommit());
return connection;
}
@Override
public void closeConnection() {
try {
if (isConnectionValid()) {
connection.close();
}
} catch (SQLException e) {
LOG.warn("JDBC connection close failed.", e);
} finally {
connection = null;
}
}
@Override
public Connection reestablishConnection() throws SQLException, ClassNotFoundException {
closeConnection();
return getOrEstablishConnection();
}
public JdbcConnectionConfig getJdbcConfig() {
return jdbcConfig;
}
public void setConnection(Connection connection) {
this.connection = connection;
}View on GitHub (pinned to cf67b549a7)
Solutions
- Fix the underlying disconnect cause (timeouts, LB idle limits, DB max_connections)
- Set TCP keepalive / socketTimeout in the JDBC URL so dead sockets fail fast
- Upgrade the JDBC driver if close of dead connections reliably throws
- Benign if it appears during reconnection and the new connection succeeds
Example fix
// before jdbc:mysql://host:3306/db // after jdbc:mysql://host:3306/db?socketTimeout=300000&connectTimeout=60000&tcpKeepAlive=true
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check before reestablish
if (connection != null && connection.isClosed()) {
connection = null; // skip close, avoid SQLException path
} Try / catch
// exception is swallowed internally (logged + connection nulled).
// For your own equivalent code:
try { if (conn != null) conn.close(); } catch (SQLException e) { LOG.warn("close failed", e); } finally { conn = null; } Prevention
- Set tcpKeepAlive and socket timeouts in JDBC URL
- Check LB/proxy idle timeout vs job duration
- Treat as benign during reconnection if the new connection succeeds
When it happens
Trigger: reestablishConnection() -> closeConnection() with a stale/broken connection; isConnectionValid() passes but connection.close() still throws (racy network failure, driver bug).
Common situations: Connection dropped by DB or intermediate LB between validation and close; drivers like older MySQL throwing on close of half-closed sockets; repeated during reconnection storms.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
- Failed to close %s via JDBC.
- Failed to finish the JDBC source read transaction. Closing t
- Failed to close the JDBC source connection after transaction
- Close JDBC writer failed.
- JDBC connection close failed.
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/a9c4ad03848cd676.
Report an issue: GitHub.