I am using HyperSQL as database for my Tomcat app. The database server is running from my application and the location of files is in webapps/myapp-folder.
Problem is, that after Linux (Centos 7) restart, the database collide somehow and the database is recreated (all data are deleted). If I restart only the Tomcat, everything is working fine.
My tomcat.service:
[Unit]
Description=Tomcat 8.5 servlet container
After=syslog.target network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
Environment="CATALINA_BASE=/opt/tomcat"
Environment="CATALINA_HOME=/opt/tomcat"
Environment="CATALINA_PID=/opt/tomcat/temp/tomcat.pid"
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
Restart=on-failure
[Install]
WantedBy=multi-user.target
The database folder has full Create and delete rights and group and owner is tomcat user.
The HSQL server is started, when my app starts and for working with database I am using Hibernate:
Properties properties = new Properties();
properties.setProperty(Environment.DRIVER, "org.hsqldb.jdbcDriver");
properties.setProperty(Environment.URL, "jdbc:hsqldb:hsql://localhost:9001/my_repository");
properties.setProperty(Environment.USER, xxx);
properties.setProperty(Environment.PASS, yyy);
properties.setProperty(Environment.DIALECT, "org.hibernate.dialect.HSQLDialect");
properties.setProperty(Environment.HBM2DDL_AUTO, "update");
What could be wrong? Why the data are always deleted after PC restart?
Thanks for any answer.
Try to change the property "HBM2DDL_AUTO" to validate, or even remove it.
This property is responsible for "Automatic schema generation".
You can find the other values or information here