Why camunda cannot create tables in two schema of same db?

The db have two schema. The first call “A”, the second called “B”.

At the first my database config connected the "A’ schema.
When I run my application the camunda created the tables in the “A” schema.

After that I changed my database config connect to “B” schema and run the application again but the camunda was not created the tables in the schema “B” and throwed an exception.
The exception says camunda cannot find the table “ATU_xxx”.

This make me confused and then I read the source code find the camunda will check the whole db to check tables is or not created.

In my case the tables in the “A” schema, the camunda think the tables are exists. Then camunda will to connection to the schema “B” to find the table. The tables does not exists in the “B” so camunda throwed that error.

This is a bug or not ? How to fix it ?

My english does not good, please forgive me.

1 Like

Hi @himly,

Can you provide any more information about your db and engine setup? Did you completely remove the connection to the “A” schema form the Process Engine configuration file?

What is the version of the Camunda engine you are using?

The Camunda engine will create all the necessary tables when an empty db schema is provided.

Cheers,
Nikola

1 Like

我也遇到了这个问题,分析过程如下:
org.camunda.bpm.engine.impl.db.AbstractPersistenceSession中的dbSchemaUpdate为更新表结构的入口。里面调用org.camunda.bpm.engine.impl.db.sql.DbSqlSession中的isTablePresent方法。该方法中调用DatabaseMetaData的getTables方法。该方法内部有个变量nullCatalogMeansCurrent。该值由mysql驱动提供。在mysql8.0版本,该值的默认值由true变成了false。导致在一个库中只要有任何一个schema存在表结构,都不会再创建表结构。
解决方案:将nullCatalogMeansCurrent的值改成true。
版本情况:
Camunda 7.10.0
Mysql Driver:8.0.13

3 Likes

Hi, @1119

I am Chinese but this website may like stack overflow is English language only.
For make sure others understand I will use English reply you.

First. Thank you so much. You saved my day. And this is working for me.
Second I will translate your answer for others.

This is because MySQL changed the nullCatalogMeansCurrent property default value to false.
if the nullCatalogMeansCurrent property value is false the MySQL will search the whole schema to find tables.
if the nullCatalogMeansCurrent property value is true the MySQL will search current schema to find tables.

How to fix it?
Just add the nullCatalogMeansCurrent property to your mysql url.
here is the example

jdbc:mysql://localhost:3306/piwik?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&nullCatalogMeansCurrent=true

Cheers

6 Likes

I just found this problem today, and followed the source code.Thank you for your translation

great, by the way I am Chinese too :handshake:

1 Like

six six six! Thank you, that’s great:grinning:

1 Like

@himly - What need to be done in case of oracle ?

Hi @Siva_kumar.

I am sorry , I am not familiar the oracle database.

Hello, @Siva_kumar! Did you find the solution regarding oracle schema in topic Why camunda cannot create tables in two schema of same db??

I saw your question right there and seems like i have the same issue.

Would be nice if you have some solution.

Thank you very much

Worked! Thanks a lot.