|
spring-jdbc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.jdbc.datasource.init.ResourceDatabasePopulator
public class ResourceDatabasePopulator
Populates a database from SQL scripts defined in external resources.
Call addScript(Resource)
to add a SQL script location.
Call setSqlScriptEncoding(String)
to set the encoding for all added scripts.
Constructor Summary | |
---|---|
ResourceDatabasePopulator()
|
Method Summary | |
---|---|
void |
addScript(org.springframework.core.io.Resource script)
Add a script to execute to populate the database. |
void |
populate(java.sql.Connection connection)
Populate the database using the JDBC connection provided. |
void |
setCommentPrefix(java.lang.String commentPrefix)
Set the line prefix that identifies comments in the SQL script. |
void |
setContinueOnError(boolean continueOnError)
Flag to indicate that all failures in SQL should be logged but not cause a failure. |
void |
setIgnoreFailedDrops(boolean ignoreFailedDrops)
Flag to indicate that a failed SQL DROP statement can be ignored. |
void |
setScripts(org.springframework.core.io.Resource[] scripts)
Set the scripts to execute to populate the database. |
void |
setSeparator(java.lang.String separator)
Specify the statement separator, if a custom one. |
void |
setSqlScriptEncoding(java.lang.String sqlScriptEncoding)
Specify the encoding for SQL scripts, if different from the platform encoding. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ResourceDatabasePopulator()
Method Detail |
---|
public void addScript(org.springframework.core.io.Resource script)
script
- the path to a SQL scriptpublic void setScripts(org.springframework.core.io.Resource[] scripts)
scripts
- the scripts to executepublic void setSqlScriptEncoding(java.lang.String sqlScriptEncoding)
encoded resources
.
addScript(Resource)
public void setSeparator(java.lang.String separator)
public void setCommentPrefix(java.lang.String commentPrefix)
public void setContinueOnError(boolean continueOnError)
public void setIgnoreFailedDrops(boolean ignoreFailedDrops)
DROP
statement can be ignored.
This is useful for non-embedded databases whose SQL dialect does not support an
IF EXISTS
clause in a DROP
. The default is false so that if the
populator runs accidentally, it will fail fast when the script starts with a DROP
.
public void populate(java.sql.Connection connection) throws java.sql.SQLException
DatabasePopulator
populate
in interface DatabasePopulator
connection
- the JDBC connection to use to populate the db; already configured and ready to use
java.sql.SQLException
- if an unrecoverable data access exception occurs during database population
|
spring-jdbc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |