Package org.xipki.datasource
Class ScriptRunner
- java.lang.Object
-
- org.xipki.datasource.ScriptRunner
-
public class ScriptRunner extends Object
Tool to run database scripts.- Author:
- Apach project iBATIS, Benoit Duffez, Lijun Liao (xipki)
-
-
Constructor Summary
Constructors Constructor Description ScriptRunner(Connection connection, boolean autoCommit, boolean stopOnError)Default constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidrunScript(Reader reader)Runs an SQL script (read in using the Reader parameter)voidrunScript(String filepath)Runs an SQL script (read in using the Reader parameter)static voidrunScript(String dbConfFile, String scriptFile, org.xipki.password.PasswordResolver passwordResolver)static voidrunScript(DataSourceWrapper dataSource, String scriptFile, org.xipki.password.PasswordResolver passwordResolver)voidsetDelimiter(String delimiter, boolean fullLineDelimiter)voidsetErrorLogWriter(PrintWriter errorLogWriter)Setter for errorLogWriter propertyvoidsetLogWriter(PrintWriter logWriter)Setter for logWriter property
-
-
-
Field Detail
-
delimP
public static final Pattern delimP
regex to detect delimiter. ignores spaces, allows delimiter in comment, allows an equals-sign
-
-
Constructor Detail
-
ScriptRunner
public ScriptRunner(Connection connection, boolean autoCommit, boolean stopOnError)
Default constructor
-
-
Method Detail
-
runScript
public static void runScript(String dbConfFile, String scriptFile, org.xipki.password.PasswordResolver passwordResolver) throws Exception
- Throws:
Exception
-
runScript
public static void runScript(DataSourceWrapper dataSource, String scriptFile, org.xipki.password.PasswordResolver passwordResolver) throws Exception
- Throws:
Exception
-
setDelimiter
public void setDelimiter(String delimiter, boolean fullLineDelimiter)
-
setLogWriter
public void setLogWriter(PrintWriter logWriter)
Setter for logWriter property- Parameters:
logWriter- - the new value of the logWriter property
-
setErrorLogWriter
public void setErrorLogWriter(PrintWriter errorLogWriter)
Setter for errorLogWriter property- Parameters:
errorLogWriter- - the new value of the errorLogWriter property
-
runScript
public void runScript(String filepath) throws IOException, SQLException
Runs 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:
IOExceptionSQLException
-
runScript
public void runScript(Reader reader) throws IOException, SQLException
Runs an SQL script (read in using the Reader parameter)- Parameters:
reader- - the source of the script- Throws:
IOExceptionSQLException
-
-