简体   繁体   English

Linux重启后删除Tomcat中的HyperSQL数据库

[英]HyperSQL database in Tomcat is deleted after Linux restart

I am using HyperSQL as database for my Tomcat app.我正在使用 HyperSQL 作为我的 Tomcat 应用程序的数据库。 The database server is running from my application and the location of files is in webapps/myapp-folder.数据库服务器从我的应用程序运行,文件的位置在 webapps/myapp-folder 中。

Problem is, that after Linux (Centos 7) restart, the database collide somehow and the database is recreated (all data are deleted).问题是,在 Linux(Centos 7)重新启动后,数据库以某种方式发生冲突并重新创建数据库(所有数据都被删除)。 If I restart only the Tomcat, everything is working fine.如果我只重启 Tomcat,一切正常。

My tomcat.service:我的 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.数据库文件夹具有完全的创建和删除权限,组和所有者是 tomcat 用户。

The HSQL server is started, when my app starts and for working with database I am using Hibernate: HSQL 服务器已启动,当我的应用程序启动并使用数据库时,我正在使用 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.尝试更改属性“HBM2DDL_AUTO”以验证,甚至删除它。
This property is responsible for "Automatic schema generation".此属性负责“自动模式生成”。
You can find the other values or information here您可以在此处找到其他值或信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM