From fbd921f25af548067abbaee399168ef3c64541e3 Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Sat, 9 May 2009 23:52:13 +0000 Subject: [PATCH] embedded db support --- spring-framework-reference/src/jdbc.xml | 81 ++++++++++++++++--- spring-framework-reference/src/new-in-3.xml | 13 +++ .../src/spring-framework-reference.xml | 12 ++- 3 files changed, 92 insertions(+), 14 deletions(-) diff --git a/spring-framework-reference/src/jdbc.xml b/spring-framework-reference/src/jdbc.xml index 4dc0f035b08..088222e4ac9 100644 --- a/spring-framework-reference/src/jdbc.xml +++ b/spring-framework-reference/src/jdbc.xml @@ -87,11 +87,10 @@ SimpleJdbcTemplate - this - class combines the most frequently used features of both - JdbcTemplate and NamedParameterJdbcTemplate plus it adds additional - convenience by taking better advantage of Java 5 varargs for - ceratain methods where this wasn't possible in the JdbcTemplate due - to backwars compatibility reasons. + class combines the most frequently used operations across + JdbcTemplate and NamedParameterJdbcTemplate. + It also adds some additional convenience around support for Java 5 varargs + where this was not possible in the JdbcTemplate due to backwards compatibility reasons. @@ -142,11 +141,9 @@ contains a utility class for easy DataSource access, and various simple DataSource implementations that can be - used for testing and running unmodified JDBC code outside of a J2EE - container. The utility class provides static methods to obtain - connections from JNDI and to close connections if necessary. It has - support for thread-bound connections, e.g. for use with - DataSourceTransactionManager. + used for testing and running unmodified JDBC code outside of a Java EE container. + A sub-package named org.springfamework.jdbc.datasource.embedded + provides support for creating in-memory database instances using Java database engines such as HSQL and H2. Next, the org.springframework.jdbc.object package contains classes that represent RDBMS queries, updates, and @@ -2513,4 +2510,68 @@ clobReader.close();]]> the stored procedure. +
+ Embedded database support + + The org.springframework.jdbc.datasource.embedded package provides support for embedded Java database engines. + Support for HSQL and H2 is provided natively. + There is also an extensible API for plugging in new embedded database types and DataSource implementations. + +
+ Why use a embedded database? + + An embedded database is useful during the development phase of a project due to its lightweight nature. + Ease of configuration, quick startup time, testability, and the ability to rapidly evolve SQL during development are just some of the benefits of using an embedded database. + +
+
+ Creating an embedded database instance using Spring XML + + When you wish to expose an embedded database instance as a bean in a Spring ApplicationContext, use the embedded-database tag in the spring-jdbc namespace: + + + + ]]> + + + + The configuration above creates an embedded HSQL database populated with SQL from schema.sql and testdata.sql resources in the classpath. + The database instance is made available to the Spring container as a bean of type javax.sql.DataSource. + This bean can then be injected into data access objects as needed. + +
+
+ + Creating an embedded database instance programatically + + + The EmbeddedDatabaseBuilder class provides a fluent API for constructing an embedded database programmatically. + Use this when you need to create an embedded database instance in a standalone environment, such as a data access object unit test: + + + +
+
+ Extending the embedded database support + + Spring Jdbc's embedded database support can be extended in two ways: + + + Implement EmbeddedDatabaseConfigurer to support a new embedded database type, such as Apache Derby. + + + Implement DataSourceFactory to support a new DataSource implementation, such as a connection pool, to manage embedded database connections. + + + + + You are encouraged to contribute back extensions to the Spring community at jira.springframework.org. + +
+
\ No newline at end of file diff --git a/spring-framework-reference/src/new-in-3.xml b/spring-framework-reference/src/new-in-3.xml index 75e78704c25..cf39e5b110e 100644 --- a/spring-framework-reference/src/new-in-3.xml +++ b/spring-framework-reference/src/new-in-3.xml @@ -196,6 +196,11 @@ Early support for Java EE 6 + + + Embedded database support + +
@@ -435,5 +440,13 @@ public class AppConfig{ Work in progress... not part of the Spring 3.0 M3 release.
+ +
+ Support for embedded databases + + Convenient support for embedded Java database engines, such as HSQL and H2, is now provided. + +
+ diff --git a/spring-framework-reference/src/spring-framework-reference.xml b/spring-framework-reference/src/spring-framework-reference.xml index 2af85d1870d..3be4290bbfd 100644 --- a/spring-framework-reference/src/spring-framework-reference.xml +++ b/spring-framework-reference/src/spring-framework-reference.xml @@ -7,7 +7,7 @@ Reference Documentation (Work in progress) Spring Framework - 3.0.M3 + 3.0.0.M3 Hoeller - Alef - Arendsen + Keith + Donald Colin @@ -39,6 +39,10 @@ Thomas Risberg + + Alef + Arendsen + Darren Davison @@ -106,7 +110,7 @@ 2004-2009 - Rod Johnson, Juergen Hoeller, Alef Arendsen, Colin Sampaleanu, Rob Harrop, Thomas Risberg, Darren Davison, + Rod Johnson, Juergen Hoeller, Keith Donald, Colin Sampaleanu, Rob Harrop, Alef Arendsen, Thomas Risberg, Darren Davison, Dmitriy Kopylenko, Mark Pollack, Thierry Templier, Erwin Vervaet, Portia Tung, Ben Hale, Adrian Colyer, John Lewis, Costin Leau, Mark Fisher, Sam Brannen, Ramnivas Laddad, Arjen Poutsma, Chris Beams, Tareq Abed Rabbo