cancel
Showing results for 
Search instead for 
Did you mean: 

Persistent H2 Database (activiti-5.10)

nommyravian
Champ in-the-making
Champ in-the-making
Hi,
I've deployed activiti-5.10 to my windows machine using demo setup instructions. Every time I start the engine, it comes up with new database and I lose added users and deployed process. How to make H2 database persistent?
Thank you.
5 REPLIES 5

frederikherema1
Star Contributor
Star Contributor
As you say, it's a demo setup. If you want to use your own database, check out the user guide for more info. Also, for running H2 on your machine, consult their documentation, it's really easy to get a h2 up and running.

nommyravian
Champ in-the-making
Champ in-the-making
Thanks for the reply.
I had been using the demo setup of activiti-5.9 for last few days and it has persistent in memory database. Now I deployed activiti-5.10 and it's dropping and recreating database every time I start the server. Why activiti-5.9 demo setup wasn't doing this? I tried searching for jdbc property in activiti.cfg.xml and in persistence.xml for activiti 5-10 but couldn't fix it.

best regards,

jbarrez
Star Contributor
Star Contributor
Are you running 'ant demo.setup' over and over again? Afaik, this wont drop/create the schema … (but I can be wrong).
What happens if you start the Tomcat server and the H2 database yourself. There are ant targets for that, run 'ant -p' from the setup folder to see them.

nommyravian
Champ in-the-making
Champ in-the-making
Hi,
I was simply using ant demo.start but now I found the issue.

There is db.properties file in the path {activiti-5.10 Home}\apps\apache-tomcat-6.0.32\webapps\activiti-explorer\WEB-INF\classes. The default contents are;

db=h2
jdbc.driver=org.h2.Driver
#jdbc.url=jdbc:h2:tcp://localhost/activiti
jdbc.url=jdbc:h2:mem:activiti
jdbc.username=sa
jdbc.password=

I commented the 4th line and used the 3rd line of jdbc.url and it worked. Now schema is not dropped and re created every time. My db.properties file is now;

db=h2
jdbc.driver=org.h2.Driver
jdbc.url=jdbc:h2:tcp://localhost/activiti
#jdbc.url=jdbc:h2:mem:activiti
jdbc.username=sa
jdbc.password=

Note: This file is updated in activiti 5-10 (I confirmed it with activiti 5-9). I don't know if activiti 5-10 developers have changed it intentionally or left the "jdbc.url=jdbc:h2:tcp://localhost/activiti" line commented mistakenly but changing this configuration solved my issue. Now I've persistent h2 db like I had in activiti 5.9  Smiley Very Happy

jbarrez
Star Contributor
Star Contributor
I do think it's an error by someone 'testing something out'.

I changed it back to the persistent db: https://github.com/Activiti/Activiti/commit/7df7452d8b4f81389a047b7c6d16679bc58f9da0