hibernate/hibernate-orm · error · IllegalStateException

Cannot close a connection as the driver manager is not…

Error message

Cannot close a connection as the driver manager is not properly initialized

What it means

closeConnection called while internal state is null: the provider was never configured/started, so there is no pool to return the connection to. IllegalStateException signalling lifecycle misuse.

Solutions

  1. Do not close connections after the provider has been stopped
  2. Initialize the provider with proper JDBC settings before use
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProvider.java:296 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/9509be987e3c6d34. Report an issue: GitHub.

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProvider.java:296

			}
		}
	}


	// use the pool ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	@Override
	public Connection getConnection() throws SQLException {
		if ( state == null ) {
			throw new IllegalStateException( "Cannot get a connection as the driver manager is not properly initialized" );
		}
		return state.getConnection();
	}

	@Override
	public void closeConnection(Connection connection) throws SQLException {
		if ( state == null ) {
			throw new IllegalStateException( "Cannot close a connection as the driver manager is not properly initialized" );
		}
		state.closeConnection( connection );
	}

	@Override
	public boolean supportsAggressiveRelease() {
		return false;
	}

	@Override
	public DatabaseConnectionInfo getDatabaseConnectionInfo(Dialect dialect) {
		return new DatabaseConnectionInfoImpl(
				DriverManagerConnectionProvider.class,
				dbInfo.getJdbcUrl(),
				dbInfo.getJdbcDriver(),
				dialect.getClass(),
				dialect.getVersion(),
				dbInfo.hasSchema(),

View on GitHub (pinned to fad1729dce)