Polish DevToolsDataSourceAutoConfiguration

pull/33545/head
Moritz Halbritter 2 years ago
parent f36e2ecb7b
commit 1754018a7b

@ -19,8 +19,6 @@ package org.springframework.boot.devtools.autoconfigure;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
@ -108,8 +106,11 @@ public class DevToolsDataSourceAutoConfiguration {
private enum InMemoryDatabase {
DERBY(null, new HashSet<>(Arrays.asList("org.apache.derby.jdbc.EmbeddedDriver")), (dataSource) -> {
String url = dataSource.getConnection().getMetaData().getURL();
DERBY(null, Set.of("org.apache.derby.jdbc.EmbeddedDriver"), (dataSource) -> {
String url;
try (Connection connection = dataSource.getConnection()) {
url = connection.getMetaData().getURL();
}
try {
new EmbeddedDriver().connect(url + ";drop=true", new Properties()).close();
}
@ -120,10 +121,10 @@ public class DevToolsDataSourceAutoConfiguration {
}
}),
H2("jdbc:h2:mem:", new HashSet<>(Arrays.asList("org.h2.Driver", "org.h2.jdbcx.JdbcDataSource"))),
H2("jdbc:h2:mem:", Set.of("org.h2.Driver", "org.h2.jdbcx.JdbcDataSource")),
HSQLDB("jdbc:hsqldb:mem:", new HashSet<>(Arrays.asList("org.hsqldb.jdbcDriver",
"org.hsqldb.jdbc.JDBCDriver", "org.hsqldb.jdbc.pool.JDBCXADataSource")));
HSQLDB("jdbc:hsqldb:mem:", Set.of("org.hsqldb.jdbcDriver", "org.hsqldb.jdbc.JDBCDriver",
"org.hsqldb.jdbc.pool.JDBCXADataSource"));
private final String urlPrefix;

Loading…
Cancel
Save