jumpserver/jumpserver · critical · DatabaseError
Cannot connect to database
Error message
Cannot connect to database
What it means
Raised by OracleClient.commit when self._conn is None — i.e. commit() was called on a client whose JDBC/DB connection was never established or has been lost. The class guards execute paths with fail_json, but commit() raises DatabaseError directly because there is no connection object to commit on.
Source
Thrown at apps/libs/ansible/modules_utils/oracle_common.py:99
result, error = None, None
try:
self.cursor.execute(sql, params)
sql_header = self.cursor.description or []
column_names = [description[0].lower() for description in sql_header]
if column_names:
result = [dict(zip(column_names, row)) for row in self.cursor]
result = result[0] if len(result) == 1 else result
else:
result = None
except DatabaseError as err:
error = err
if exception_to_fail and error:
self.module.fail_json(msg='Cannot execute sql: %s' % to_native(error))
return result, error
def commit(self):
if self._conn is None:
raise DatabaseError('Cannot connect to database')
self._conn.commit()
def close(self):
try:
if self._cursor:
self._cursor.close()
if self._conn:
self._conn.close()
except:
pass
View on GitHub (pinned to 6ec464fabd)
Solutions
- Check the connect step's result/error before calling commit; abort on connection failure
- Ensure connect() succeeded (self._conn is not None) — inspect why the connection is missing (credentials, listener, network)
- Structure the flow as connect -> execute -> commit -> close with early exit on the first failure
Example fix
# before
client.connect()
result, err = client.execute(sql)
client.commit() # DatabaseError if connect failed silently
# after
client.connect()
if client._conn is None:
module.fail_json(msg='Oracle connection failed')
result, err = client.execute(sql)
if not err:
client.commit() Defensive patterns
Strategy: try-catch
Validate before calling
if getattr(client, '_conn', None) is None:
module.fail_json(msg='Oracle connection not established; aborting before commit') Type guard
null
Try / catch
try:
client.commit()
except DatabaseError as e:
module.fail_json(msg=f'Commit failed: {e}') Prevention
- Abort the task as soon as connect fails; never continue to commit
- Wrap connect/execute/commit in one try block with early fail_json
- Monitor connection liveness for long-running Oracle push tasks
When it happens
Trigger: Calling commit() after connect() failed but the failure was swallowed (exception_to_fail=False or error ignored); calling commit() after close() or after the underlying connection dropped; the main flow reaching the commit step for user_add/user_change_password without a prior successful connect.
Common situations: Oracle asset with wrong host/port/credentials where connect errors were logged but execution continued; network drop mid-task before commit; code paths that call commit() unconditionally after a try/except that swallowed the connect exception.
Related errors
- InvalidElasticsearch
- Password is required for 'password' authentication type
- Unsupported authentication type: {auth_type}
- SSH shell channel is not available
- SSH shell channel closed during handshake
AI-assisted analysis of jumpserver/jumpserver@6ec464fabd (2026-08-28).
Data as JSON: /api/errors/3be64546d9379e32.
Report an issue: GitHub.