Top Description Fields Constructors Methods
org.springframework.jdbc.datasource.init

public Class CompositeDatabasePopulator

extends Object
implements DatabasePopulator
Class Inheritance
All Implemented Interfaces
org.springframework.jdbc.datasource.init.DatabasePopulator
Imports
java.sql.Connection, .SQLException, java.util.ArrayList, .Arrays, .Collection, .List, org.springframework.util.Assert

Composite DatabasePopulator that delegates to a list of given DatabasePopulator implementations, executing all scripts.
Authors
Dave Syer, Juergen Hoeller, Sam Brannen, Kazuki Shimizu
Since
3.1

Field Summary

Modifier and TypeField and Description
private final List<DatabasePopulator>

Constructor Summary

AccessConstructor and Description
public
CompositeDatabasePopulator()

Create an empty CompositeDatabasePopulator.

public
CompositeDatabasePopulator(Collection<DatabasePopulator>
one or more populators to delegate to
populators
)

Create a CompositeDatabasePopulator with the given populators.

public
CompositeDatabasePopulator(DatabasePopulator...
one or more populators to delegate to
populators
)

Create a CompositeDatabasePopulator with the given populators.

Method Summary

Modifier and TypeMethod and Description
public void
addPopulators(DatabasePopulator... populators)

Add one or more populators to the list of delegates.

public void
populate(Connection
the JDBC connection to use; already configured and ready to use; never null
connection
)

Implements org.springframework.jdbc.datasource.init.DatabasePopulator.populate.

Populate, initialize, or clean up the database using the provided JDBC connection.
public void
setPopulators(DatabasePopulator... populators)

Specify one or more populators to delegate to.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

populatorsback to summary
private final List<DatabasePopulator> populators

Constructor Detail

CompositeDatabasePopulatorback to summary
public CompositeDatabasePopulator()

Create an empty CompositeDatabasePopulator.

See Also
setPopulators, addPopulators
CompositeDatabasePopulatorback to summary
public CompositeDatabasePopulator(Collection<DatabasePopulator> populators)

Create a CompositeDatabasePopulator with the given populators.

Parameters
populators:Collection<DatabasePopulator>

one or more populators to delegate to

Since
4.3
CompositeDatabasePopulatorback to summary
public CompositeDatabasePopulator(DatabasePopulator... populators)

Create a CompositeDatabasePopulator with the given populators.

Parameters
populators:DatabasePopulator[]

one or more populators to delegate to

Since
4.3

Method Detail

addPopulatorsback to summary
public void addPopulators(DatabasePopulator... populators)

Add one or more populators to the list of delegates.

populateback to summary
public void populate(Connection connection) throws SQLException, ScriptException

Implements org.springframework.jdbc.datasource.init.DatabasePopulator.populate.

Doc from org.springframework.jdbc.datasource.init.DatabasePopulator.populate.

Populate, initialize, or clean up the database using the provided JDBC connection.

Warning

Concrete implementations should not close the provided Connection.

Concrete implementations may throw an SQLException if an error is encountered but are strongly encouraged to throw a specific ScriptException instead. For example, Spring's ResourceDatabasePopulator and DatabasePopulatorUtils wrap all SQLExceptions in ScriptExceptions.

Parameters
connection:Connection

the JDBC connection to use; already configured and ready to use; never null

Annotations
@Override
Exceptions
SQLException:
if an unrecoverable data access exception occurs while interacting with the database
ScriptException:
in all other error cases
setPopulatorsback to summary
public void setPopulators(DatabasePopulator... populators)

Specify one or more populators to delegate to.