cancel
Showing results for 
Search instead for 
Did you mean: 

mysql DB Connection problem

andreanucifora
Champ in-the-making
Champ in-the-making
Hi All,

i'm encountering a problem during mysql database connection.
below the sequence steps i followed:

1) creation of "Activiti" database and user into mysql server
2) deploying of mysql connector to tomcat Lib folder (mysql-connector-java-5.1.21.jar)
3) modification of db.properties file in order to connect to Activiti database

db=activiti
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/activiti?autoReconnect=true
jdbc.username=activiti
jdbc.password=*

4) reboot of tomcat
5) creation of an "activiti.cfg.xml" file placed on src/main/resources path of my eclipse project

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd">

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" >
  <property name="driverClassName" value="com.mysql.jdbc.Driver" />
  <property name="url" value="jdbc:mysql://localhost:3306/activiti" />
  <property name="username" value="activiti" />
  <property name="password" value="*" />
  <property name="defaultAutoCommit" value="false" />
</bean>     

<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
    <property name="dataSource" ref="dataSource" />
</bean>
</beans>

6) Maven refresh of the project (mvn eclipse:eclipse)

My App contains only the following test code:

     public static void main(String[] args) {
      
      ProcessEngineConfiguration pec = ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault();
      System.out.println(pec.getDataSourceJndiName());
      System.out.println(pec.getJdbcDriver());
      System.out.println(pec.getJdbcUrl());
      System.out.println(pec.getJdbcUsername());
      System.out.println(pec.getJdbcPassword());
}

but the result is the following:


null
org.h2.Driver
jdbc:h2:tcp://localhost/activiti
sa

Point of attention: the schema was created on db 'activiti' when i restarted.

My activiti version is 5.14
My tomcat version is 7.0.42
My mysql version is 5.6.11

Please tell me if you need more information or if you already discussed about the solution in other threads
(i have searched in forum from top to bottom but unsuccessfully).

Thank you in advance!
Andrea
1 REPLY 1

frederikherema1
Star Contributor
Star Contributor
Printing out the values of pec.getJdbcDriver() will always return the "defaults" (being H2) unless you override those settings. I see you're using a datasource. Activiti will IGNORE the jdbc-properties on the PEConfiguration and will use the datasource instread to get connections from. Try logging/syso'ing the datasource and it's parameters to check what DB is actually used, instead of looking at the raw (unused) properties.