Package org.springframework.jdbc.datasource.init

# Interface DatabasePopulator

All Known Implementing Classes:
  `CompositeDatabasePopulator`, `ResourceDatabasePopulator`

Functional Interface:
  This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface DatabasePopulator
Strategy used to populate, initialize, or clean up a database.

Since:
  3.0
Author:
  Keith Donald, Sam Brannen
See Also:
  - `ResourceDatabasePopulator`
  - `DatabasePopulatorUtils`
  - `DataSourceInitializer`

## Method Summary

Modifier and Type
Method
Description
`void`
`populate(Connection connection)`
Populate, initialize, or clean up the database using the provided JDBC connection.

## Method Details

### populate

void populate(Connection connection) throws SQLException, ScriptException
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` - the JDBC connection to use; already configured and ready to use; never `null`
Throws:
  `SQLException` - if an unrecoverable data access exception occurs while interacting with the database
  `ScriptException` - in all other error cases
See Also:
  - `DatabasePopulatorUtils.execute(org.springframework.jdbc.datasource.init.DatabasePopulator, javax.sql.DataSource)`