Set DB_CLOSE_ON_EXIT=false in H2EmbeddedDbConfig

This commit sets the DB_CLOSE_ON_EXIT flag to false for embedded H2
databases loaded using H2EmbeddedDatabaseConfigurer (i.e., via Spring's
<jdbc:embedded-database /> XML namespace, EmbeddedDatabaseBuilder,
EmbeddedDatabaseFactory, and EmbeddedDatabaseFactoryBean).

Issue: SPR-11573
This commit is contained in:
Sam Brannen
2014-03-19 01:22:46 +01:00
parent dc6d67510d
commit 8aefcb9a55
3 changed files with 70 additions and 48 deletions

View File

@@ -26,6 +26,7 @@ import org.springframework.util.ClassUtils;
*
* @author Oliver Gierke
* @author Juergen Hoeller
* @author Sam Brannen
* @since 3.0
*/
final class H2EmbeddedDatabaseConfigurer extends AbstractEmbeddedDatabaseConfigurer {
@@ -36,7 +37,7 @@ final class H2EmbeddedDatabaseConfigurer extends AbstractEmbeddedDatabaseConfigu
/**
* Get the singleton {@link H2EmbeddedDatabaseConfigurer} instance.
* Get the singleton {@code H2EmbeddedDatabaseConfigurer} instance.
* @return the configurer
* @throws ClassNotFoundException if H2 is not on the classpath
*/
@@ -57,7 +58,7 @@ final class H2EmbeddedDatabaseConfigurer extends AbstractEmbeddedDatabaseConfigu
@Override
public void configureConnectionProperties(ConnectionProperties properties, String databaseName) {
properties.setDriverClass(this.driverClass);
properties.setUrl(String.format("jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1", databaseName));
properties.setUrl(String.format("jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false", databaseName));
properties.setUsername("sa");
properties.setPassword("");
}