提交 0cc3542a 编写于 作者: K Keith Donald

applied joris's no derby log patch

上级 72c330ff
......@@ -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
......
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册