Projects
Mega:24.03:SP1:Everything
springframework
_service:tar_scm:springframework-3.2.13-derby.p...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:springframework-3.2.13-derby.patch of Package springframework
--- spring-framework-3.2.13.RELEASE/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/DerbyEmbeddedDatabaseConfigurer.java 2014-12-30 17:22:59.000000000 +0100 +++ spring-framework-3.2.13.RELEASE/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/DerbyEmbeddedDatabaseConfigurer.java.derby 2015-03-06 13:41:54.412646283 +0100 @@ -16,19 +16,16 @@ package org.springframework.jdbc.datasource.embedded; -import java.io.File; -import java.io.IOException; import java.sql.SQLException; import java.util.Properties; import javax.sql.DataSource; -import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.derby.impl.io.VFMemoryStorageFactory; import org.apache.derby.jdbc.EmbeddedDriver; /** - * {@link EmbeddedDatabaseConfigurer} for the Apache Derby database. + * {@link EmbeddedDatabaseConfigurer} for the Apache Derby database 10.6+. + * <p>Call {@link #getInstance()} to get the singleton instance of this class. * * @author Oliver Gierke * @author Juergen Hoeller @@ -36,14 +33,9 @@ */ final class DerbyEmbeddedDatabaseConfigurer implements EmbeddedDatabaseConfigurer { - private static final Log logger = LogFactory.getLog(DerbyEmbeddedDatabaseConfigurer.class); - private static final String URL_TEMPLATE = "jdbc:derby:memory:%s;%s"; - // Error code that indicates successful shutdown - private static final String SHUTDOWN_CODE = "08006"; - - private static DerbyEmbeddedDatabaseConfigurer INSTANCE; + private static DerbyEmbeddedDatabaseConfigurer instance; /** @@ -52,18 +44,20 @@ * @throws ClassNotFoundException if Derby is not on the classpath */ public static synchronized DerbyEmbeddedDatabaseConfigurer getInstance() throws ClassNotFoundException { - if (INSTANCE == null) { + if (instance == null) { // disable log file System.setProperty("derby.stream.error.method", OutputStreamFactory.class.getName() + ".getNoopOutputStream"); - INSTANCE = new DerbyEmbeddedDatabaseConfigurer(); + instance = new DerbyEmbeddedDatabaseConfigurer(); } - return INSTANCE; + return instance; } + private DerbyEmbeddedDatabaseConfigurer() { } + @Override public void configureConnectionProperties(ConnectionProperties properties, String databaseName) { properties.setDriverClass(EmbeddedDriver.class); properties.setUrl(String.format(URL_TEMPLATE, databaseName, "create=true")); @@ -71,28 +65,16 @@ properties.setPassword(""); } + @Override public void shutdown(DataSource dataSource, String databaseName) { - EmbeddedDriver embeddedDriver = new EmbeddedDriver(); - boolean isAtLeastDotSix = (embeddedDriver.getMinorVersion() >= 6); - String shutdownCommand = String.format("%s=true", isAtLeastDotSix ? "drop" : "shutdown"); try { - embeddedDriver.connect( - String.format(URL_TEMPLATE, databaseName, shutdownCommand), new Properties()); + new EmbeddedDriver().connect( + String.format(URL_TEMPLATE, databaseName, "drop=true"), new Properties()); } catch (SQLException ex) { - if (!SHUTDOWN_CODE.equals(ex.getSQLState())) { - logger.warn("Could not shutdown in-memory Derby database", ex); - return; - } - if (!isAtLeastDotSix) { - // Explicitly purge the in-memory database, to prevent it - // from hanging around after being shut down. - try { - VFMemoryStorageFactory.purgeDatabase(new File(databaseName).getCanonicalPath()); - } - catch (IOException ex2) { - logger.warn("Could not purge in-memory Derby database", ex2); - } + // Error code that indicates successful shutdown + if (!"08006".equals(ex.getSQLState())) { + LogFactory.getLog(getClass()).warn("Could not shutdown in-memory Derby database", ex); } } }
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2