GitLab steht aufgrund wichtiger Wartungsarbeiten am Montag, den 8. März, zwischen 17:00 und 19:00 Uhr nicht zur Verfügung.

Commit 5e30269d authored by Daniel Gerhardt's avatar Daniel Gerhardt

Ensure clean shutdown of HSQLDB

parent 0c8ebfe2
......@@ -3,6 +3,8 @@ package de.thm.arsnova.connector.config;
import java.sql.SQLException;
import java.util.Properties;
import javax.annotation.PreDestroy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
......@@ -48,8 +50,8 @@ public class AppConfig {
}
@Bean(name = "configDataSource")
public DriverManagerDataSource configDataSource() throws SQLException {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
public HsqlDataSource configDataSource() throws SQLException {
HsqlDataSource dataSource = new HsqlDataSource();
dataSource.setDriverClassName("org.hsqldb.jdbc.JDBCDriver");
dataSource.setUrl("jdbc:hsqldb:file:/etc/arsnova/connector.db");
dataSource.setUsername("whatever");
......@@ -97,4 +99,16 @@ public class AppConfig {
}
return null;
}
private class HsqlDataSource extends DriverManagerDataSource {
@PreDestroy
public void shutdown() {
logger.info("Shutting down HSQLDB");
try {
this.getConnection().createStatement().execute("SHUTDOWN;");
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment