cancel
Showing results for 
Search instead for 
Did you mean: 

Possible bug when using MS-SQL server configuration

tommyalf
Champ in-the-making
Champ in-the-making
Hi all,
  when I use this configuration:

<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
        <property name="dataSource" ref="dataSource"/>
        <property name="transactionManager" ref="transactionManager"/>
        <property name="databaseSchemaUpdate" value="false"/>
        <property name="databaseSchema" value="mySchema"/>
        <property name="databaseTablePrefix" value="mySchema."/>
    …..
    </bean>
I receive this error:
org.activiti.engine.ActivitiException: Activiti database problem: Tables missing for component(s) engine, history, identity

This is because JTDS ( it is my jdbc connector but I investigated also on SQLJDBC which it has the same behaviour)
uses 'sp_tables' system stored procedure when check Table Metadata. 'sp_tables' fails because the name of table is changed by :
tableName = prependDatabaseTablePrefix(tableName);   (isTablePresent – DbSqlSession - 766).

Use prependDatabase seems a rigth thing but in this case causes the store procededure fail.

On the contrary I can't remove "databaseTablePrefix" because activiti tables are under a not default schema for my db user.
If I remove it Activiti will be not able to find tables.











 




2 REPLIES 2

tommyalf
Champ in-the-making
Champ in-the-making
I solve it. I change DbSqlSession (5.15-SNAPSHOT) :



public boolean isEngineTablePresent(){
    return isTablePresent("ACT_RU_EXECUTION") || isTablePresent(prependDatabaseTablePrefix("ACT_RU_EXECUTION"));
  }
  public boolean isHistoryTablePresent(){
    return isTablePresent("ACT_HI_PROCINST")  || isTablePresent(prependDatabaseTablePrefix("ACT_HI_PROCINST"));
  }
  public boolean isIdentityTablePresent(){
    return isTablePresent("ACT_ID_USER")   || isTablePresent(prependDatabaseTablePrefix("ACT_ID_USER"));
  }

  public boolean isTablePresent(String tableName) {
//    tableName = prependDatabaseTablePrefix(tableName);
    Connection connection = null;
    try {
      connection = sqlSession.getConnection();
      DatabaseMetaData databaseMetaData = connection.getMetaData();
      ResultSet tables = null;
     
      String schema = this.connectionMetadataDefaultSchema;
      if (dbSqlSessionFactory.getDatabaseSchema()!=null) {
        schema = dbSqlSessionFactory.getDatabaseSchema();


What do you think?

jbarrez
Star Contributor
Star Contributor
hmm it is a right fix for your use case - but more generically Im wondering if it wouldn't  cause issues for people … i mean what if there is a prefix AND one without prefix … ?