From 0cc3542aed8b9a4b1cc0cb2476dafac084173612 Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Sun, 17 May 2009 15:39:17 +0000 Subject: [PATCH] applied joris's no derby log patch --- .../resources/changelog.txt | 2 +- .../DerbyEmbeddedDatabaseConfigurer.java | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/build-spring-framework/resources/changelog.txt b/build-spring-framework/resources/changelog.txt index 041cf396c0..8dfcccc55b 100644 --- a/build-spring-framework/resources/changelog.txt +++ b/build-spring-framework/resources/changelog.txt @@ -17,7 +17,7 @@ Changes in version 3.0.0.RC1 (2009-06-10) * ReloadableResourceBundleMessageSource correctly calculates filenames for all locales now * @Import detects and accepts existing configuration class of the desired type * @Transactional supports qualifier value for choosing between multiple transaction managers -* added spring-jdbc config schema with initial embedded-database tag (supporting HSQL and H2) +* added spring-jdbc config schema with embedded-database tag (supporting HSQL, H2, and Derby) * Velocity/FreeMarker/TilesViewResolver only return a view if the target resource exists now diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/DerbyEmbeddedDatabaseConfigurer.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/DerbyEmbeddedDatabaseConfigurer.java index c489abed45..24db3f2963 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/DerbyEmbeddedDatabaseConfigurer.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/DerbyEmbeddedDatabaseConfigurer.java @@ -17,6 +17,7 @@ package org.springframework.jdbc.datasource.embedded; import java.io.File; import java.io.IOException; +import java.io.OutputStream; import java.sql.Connection; import java.sql.SQLException; @@ -55,6 +56,9 @@ final class DerbyEmbeddedDatabaseConfigurer implements EmbeddedDatabaseConfigure */ public static synchronized DerbyEmbeddedDatabaseConfigurer getInstance() throws ClassNotFoundException { if (INSTANCE == null) { + // disable log file + System.setProperty("derby.stream.error.method", + DerbyEmbeddedDatabaseConfigurer.class.getName() + ".getNoopOutputStream"); ClassUtils.forName("org.apache.derby.jdbc.EmbeddedDriver", DerbyEmbeddedDatabaseConfigurer.class .getClassLoader()); INSTANCE = new DerbyEmbeddedDatabaseConfigurer(); @@ -102,4 +106,17 @@ final class DerbyEmbeddedDatabaseConfigurer implements EmbeddedDatabaseConfigure } } -} + + /** + * Returns an {@link OutputStream} that ignores all data given to it. + * Used by {@link #getInstance()} to prevent writing to Derby.log file. + */ + static OutputStream getNoopOutputStream() { + return new OutputStream() { + public void write(int b) throws IOException { + // ignore the input + } + }; + } + +} \ No newline at end of file