{"record":{"id":"17363fdb5800e040","repo":"flowable/flowable-engine","slug":"could-not-set-database-catalog-on-connection","errorCode":null,"errorMessage":"Could not set database catalog on connection","messagePattern":"Could not set database catalog on connection","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/db/DbSqlSessionFactory.java","lineNumber":95,"sourceCode":"    public Class<?> getSessionType() {\n        return DbSqlSession.class;\n    }\n\n    @Override\n    public Session openSession(CommandContext commandContext) {\n        DbSqlSession dbSqlSession = createDbSqlSession();\n        if (getDatabaseSchema() != null && getDatabaseSchema().length() > 0) {\n            try {\n                dbSqlSession.getSqlSession().getConnection().setSchema(getDatabaseSchema());\n            } catch (SQLException e) {\n                throw new FlowableException(\"Could not set database schema on connection\", e);\n            }\n        }\n        if (getDatabaseCatalog() != null && getDatabaseCatalog().length() > 0) {\n            try {\n                dbSqlSession.getSqlSession().getConnection().setCatalog(getDatabaseCatalog());\n            } catch (SQLException e) {\n                throw new FlowableException(\"Could not set database catalog on connection\", e);\n            }\n        }\n        if (dbSqlSession.getSqlSession().getConnection() == null) {\n            throw new FlowableException(\"Invalid dbSqlSession: no active connection found\");\n        }\n        return dbSqlSession;\n    }\n\n    protected DbSqlSession createDbSqlSession() {\n        return new DbSqlSession(this, Context.getCommandContext().getSession(EntityCache.class));\n    }\n\n    // insert, update and delete statements\n    // /////////////////////////////////////\n\n    public String getInsertStatement(Entity object) {\n        return getStatement(object.getClass(), insertStatements, \"insert\");\n    }","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/db/DbSqlSessionFactory.java#L77-L113","documentation":"Thrown by DbSqlSessionFactory.openSession when applying the configured database catalog to the JDBC connection fails with SQLException; session setup is aborted because queries would target the wrong catalog.","triggerScenarios":"databaseCatalog is configured and connection.setCatalog throws — catalog (database name) does not exist, user lacks access, or driver rejects the call.","commonSituations":"MySQL/SQL Server catalog typo; catalog dropped or renamed; permissions changed; driver incompatibility with setCatalog.","solutions":["Confirm the catalog/database exists and the user can connect to it.","Check the databaseCatalog value spelling/case.","Alternatively encode the catalog in the JDBC URL and remove the databaseCatalog property.","Upgrade the JDBC driver to a version supporting setCatalog for your DBMS."],"exampleFix":"// before\n<property name=\"databaseCatalog\" value=\"flowable_db\" /> // db renamed\n// after\n<property name=\"databaseCatalog\" value=\"flowable_prod\" />","handlingStrategy":"validation","validationCode":"try (Connection c = dataSource.getConnection()) {\n  DatabaseMetaData md = c.getMetaData();\n  try (ResultSet rs = md.getSchemas()) {\n    boolean found = false;\n    while (rs.next()) { if (schema.equalsIgnoreCase(rs.getString(\"TABLE_SCHEM\"))) found = true; }\n    if (!found) throw new IllegalStateException(\"Schema not found: \" + schema);\n  }\n  c.setSchema(schema); // fail fast outside engine startup\n}","typeGuard":null,"tryCatchPattern":"try { engineConfiguration.buildProcessEngine(); }\ncatch (FlowableException e) {\n  if (e.getMessage().contains(\"set database schema\")) { /* check schema existence/permissions or unset databaseSchema */ }\n  throw e;\n}","preventionTips":["Create and grant the schema before engine startup.","Match schema name case to the DBMS convention.","Test connection + setSchema with a plain JDBC probe in CI.","Prefer configuring schema via JDBC URL when driver support is questionable."],"tags":["database","jdbc","configuration","catalog"],"backgroundTag":"database-query-failed","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}