spring-framework / org.springframework.jdbc.datasource.embedded

Package org.springframework.jdbc.datasource.embedded

Types

EmbeddedDatabase

interface EmbeddedDatabase : DataSource

EmbeddedDatabase serves as a handle to an embedded database instance.

An EmbeddedDatabase is also a DataSource and adds a #shutdown operation so that the embedded database instance can be shut down gracefully.

EmbeddedDatabaseBuilder

open class EmbeddedDatabaseBuilder

A builder that provides a convenient API for constructing an embedded database. Usage Example

 EmbeddedDatabase db = new EmbeddedDatabaseBuilder() .generateUniqueName(true) .setType(H2) .setScriptEncoding("UTF-8") .ignoreFailedDrops(true) .addScript("schema.sql") .addScripts("user_data.sql", "country_data.sql") .build(); // perform actions against the db (EmbeddedDatabase extends javax.sql.DataSource) db.shutdown(); 

EmbeddedDatabaseConfigurer

interface EmbeddedDatabaseConfigurer

EmbeddedDatabaseConfigurer encapsulates the configuration required to create, connect to, and shut down a specific type of embedded database such as HSQL, H2, or Derby.

EmbeddedDatabaseFactory

open class EmbeddedDatabaseFactory

Factory for creating an EmbeddedDatabase instance.

Callers are guaranteed that the returned database has been fully initialized and populated.

The factory can be configured as follows:

After configuring the factory, call #getDatabase() to obtain a reference to the EmbeddedDatabase instance.

EmbeddedDatabaseFactoryBean

open class EmbeddedDatabaseFactoryBean : EmbeddedDatabaseFactory, FactoryBean<DataSource>, InitializingBean, DisposableBean

A subclass of EmbeddedDatabaseFactory that implements FactoryBean for registration as a Spring bean. Returns the actual DataSource that provides connectivity to the embedded database to Spring.

The target DataSource is returned instead of an EmbeddedDatabase proxy since the FactoryBean will manage the initialization and destruction lifecycle of the embedded database instance.

Implements DisposableBean to shutdown the embedded database when the managing Spring container is being closed.

OutputStreamFactory

open class OutputStreamFactory

Internal helper for exposing dummy OutputStreams to embedded databases such as Derby, preventing the creation of a log file.