Package org.xipki.datasource
Class ScriptRunner
- java.lang.Object
-
- org.xipki.datasource.ScriptRunner
-
public class ScriptRunner extends java.lang.ObjectTool to run database scripts.- Author:
- Apach project iBATIS, Benoit Duffez, Lijun Liao (xipki)
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.regex.PatterndelimPregex to detect delimiter.
-
Constructor Summary
Constructors Constructor Description ScriptRunner(java.sql.Connection connection, boolean stopOnError)Default constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidrunScript(java.io.Reader reader)Runs an SQL script (read in using the Reader parameter)voidrunScript(java.lang.String filepath)Runs an SQL script (read in using the Reader parameter)static voidrunScript(java.lang.String dbConfFile, java.lang.String scriptFile)static voidrunScript(java.sql.Connection conn, java.lang.String scriptFile)static voidrunScript(DataSourceWrapper dataSource, java.lang.String scriptFile)voidsetDelimiter(java.lang.String delimiter, boolean fullLineDelimiter)voidsetErrorLogWriter(java.io.PrintWriter errorLogWriter)Setter for errorLogWriter propertyvoidsetLogWriter(java.io.PrintWriter logWriter)Setter for logWriter property
-
-
-
Method Detail
-
runScript
public static void runScript(java.lang.String dbConfFile, java.lang.String scriptFile) throws java.lang.Exception- Throws:
java.lang.Exception
-
runScript
public static void runScript(DataSourceWrapper dataSource, java.lang.String scriptFile) throws java.lang.Exception
- Throws:
java.lang.Exception
-
runScript
public static void runScript(java.sql.Connection conn, java.lang.String scriptFile) throws java.lang.Exception- Throws:
java.lang.Exception
-
setDelimiter
public void setDelimiter(java.lang.String delimiter, boolean fullLineDelimiter)
-
setLogWriter
public void setLogWriter(java.io.PrintWriter logWriter)
Setter for logWriter property- Parameters:
logWriter- - the new value of the logWriter property
-
setErrorLogWriter
public void setErrorLogWriter(java.io.PrintWriter errorLogWriter)
Setter for errorLogWriter property- Parameters:
errorLogWriter- - the new value of the errorLogWriter property
-
runScript
public void runScript(java.lang.String filepath) throws java.io.IOException, java.sql.SQLExceptionRuns an SQL script (read in using the Reader parameter)- Parameters:
filepath- - the filepath of the script to run. May be relative to the userDirectory.- Throws:
java.sql.SQLException- if any SQL errors occurjava.io.IOException- if there is an error reading from the Reader
-
runScript
public void runScript(java.io.Reader reader) throws java.io.IOException, java.sql.SQLExceptionRuns an SQL script (read in using the Reader parameter)- Parameters:
reader- - the source of the script- Throws:
java.sql.SQLException- if any SQL errors occurjava.io.IOException- if there is an error reading from the Reader
-
-