cancel
Showing results for 
Search instead for 
Did you mean: 

Change the H2 database doesn't work

paco67
Champ in-the-making
Champ in-the-making
Hello,

I need to switch between the embedded H2 database to the persistent H2 database.

I installed and started the H2 database version 2014-04-05.

I copied activiti-explorer.war and activiti-rest.war into tomcat webapp and started to deply the apps.

I turned off tomcat and modified both db.properties as:

db=h2
jdbc.driver=org.h2.Driver
#jdbc.url=jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000
jdbc.url=jdbc:h2:tcp://10.200.14.22/activity
jdbc.username=sa
jdbc.password=

When I start Tomcat, Activiti Explorer starts but it doesn't switch to the persistent H2 db.

Any idea?
5 REPLIES 5

jbarrez
Star Contributor
Star Contributor
Which Activiti version are you trying this on?

On the latest version, the jdbc.url property is used, but default to H2 if not found, see https://github.com/Activiti/Activiti/blob/master/modules/activiti-webapp-explorer2/src/main/java/org...

You sure the db properties is on the classpath?

paco67
Champ in-the-making
Champ in-the-making
Thanks for your help.

I tried Activiti 5.17 and 5.13. I changed the jdbc.url string into "db.properties" under C:\Tomcat-8.0.17\webapps\activiti-explorer\WEB-INF\classes and under C:\Tomcat-8.0.17\webapps\activiti-rest\WEB-INF\classes.

What do you mean the db.properties file is "on the classpath" ?

paco67
Champ in-the-making
Champ in-the-making
Sorry I'm a newbie, today I tried to use JNDI:

1. Into activiti-explorer webapp, replaced the META-INF\context.xml with:

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/activiti-explorer"/>
<Resource auth="Container" name="jdbc/activitiDB" type="javax.sql.DataSource" scope="Shareable" description="JDBC DataSource" url="jdbc.url=jdbc:h2:tcp://localhost/activity" driverClassName="org.h2.Driver" username="sa" password="" defaultAutoCommit="false" initialSize="5" maxWait="5000" maxActive="120" maxIdle="5"/> </Context>

2. Opened the Spring configuration files:

activiti-explorer/WEB-INF/activiti-standalone-context.xml
activiti-rest/WEB-INF/classes/activiti-context.xml

I delete the beans named "dbProperties" and "dataSource".
I add the bean:

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/activitiDB"/>
</bean>

Unfortunatelly it doesn’t work.


paco67
Champ in-the-making
Champ in-the-making
I don't know why but the XML code has been deleted.

paco67
Champ in-the-making
Champ in-the-making
Dear jbarrez I solved,

the connection string "jdbc.url=jdbc:h2:tcp://localhost/activity" into db.properties is wrong.

The correct one is "jdbc.url=jdbc\:h2\:tcp\://localhost/activiti" and now it works.

Thanks and regards.