Cannot create a processEngine via java api


#1

My default engine datasource config is

datasource:
url: jdbc:mysql://localhost:13306/hikedu_backend?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=GMT&zeroDateTimeBehavior=CONVERT_TO_NULL
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
initialization-mode: never

The second engine datasource config is

datasource:
url: jdbc:mysql://localhost:13306/hikedu_default?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=GMT&zeroDateTimeBehavior=CONVERT_TO_NULL
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
initialization-mode: never

How I do for create the second engine ?
I created a class that is implemented the ApplicationRunner interface
The code of for create second engine was writed in the run method.
Here is the code

SpringProcessEngineConfiguration.createStandaloneProcessEngineConfiguration()
.setDataSource(dataSource)
.setProcessEngineName(“second”)
.setDatabaseSchemaUpdate(“true”)
.setHistory(ProcessEngineConfiguration.HISTORY_FULL)
.buildProcessEngine();

The database of the second engine was empty but camunda says :

 2018-12-12 17:20:07,803 ERROR [restartedMain] o.c.b.e.context [BaseLogger.java:156] ENGINE-16004 Exception while closing command context: 
### Error querying database.  Cause: java.sql.SQLSyntaxErrorException: Table 'hikedu_default.ACT_GE_PROPERTY' doesn't exist
### The error may exist in org/camunda/bpm/engine/impl/mapping/entity/Property.xml
### The error may involve org.camunda.bpm.engine.impl.persistence.entity.PropertyEntity.selectProperty-Inline
### The error occurred while setting parameters
### SQL: select * from ACT_GE_PROPERTY where NAME_ = ?
### Cause: java.sql.SQLSyntaxErrorException: Table 'hikedu_default.ACT_GE_PROPERTY' doesn't exist
org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.sql.SQLSyntaxErrorException: Table 'hikedu_default.ACT_GE_PROPERTY' doesn't exist
### The error may exist in org/camunda/bpm/engine/impl/mapping/entity/Property.xml
### The error may involve org.camunda.bpm.engine.impl.persistence.entity.PropertyEntity.selectProperty-Inline
### The error occurred while setting parameters
### SQL: select * from ACT_GE_PROPERTY where NAME_ = ?
### Cause: java.sql.SQLSyntaxErrorException: Table 'hikedu_default.ACT_GE_PROPERTY' doesn't exist

If i change the datasource of second engine to another mysql instance then camunda work all right.
New datasource config is (The port changed to 33306 that is a new mysql instance)

datasource:
url: jdbc:mysql://localhost:33306/hikedu_default?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=GMT&zeroDateTimeBehavior=CONVERT_TO_NULL
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
initialization-mode: never

I was think camunda will create the tables of itself to the hikedu_default database but camunda did not. This make me confused.

Thanks you all. Please help me.


Why camunda cannot create tables?
#2

Hi @himly,

The exception says that the Camunda tables don’t exist in the schema you specified. You must create them before you start the engine. The scripts can be found in the Camunda distributions.

Cheers,
Thorben


#3

Hi @thorben ,

Thank you for your reply that is helped me so much.
But I still have a question about camunda.

I was think the camunda will create the tables automally if the tables is not exists in the database.
For make sure I am not wrong about this I test a lot. And finally I find camunda will not create the tables automally at the two schema of same database but will create the table automally only in one schema for each database.

So my question is why camunda will not create tables automally in two schema of same database.
And how I can do for make sure camunda will create tables in two schema of same database automally.
Thans you.