Package com.privalia.qa.utils
Class ScriptRunner
- java.lang.Object
-
- com.privalia.qa.utils.ScriptRunner
-
public class ScriptRunner extends Object
Tool to run database scripts
-
-
Constructor Summary
Constructors Constructor Description ScriptRunner(Connection connection, boolean autoCommit, boolean stopOnError)
Default constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResultSet
getFinalResultSet()
boolean
isHasResults()
void
runScript(Reader reader)
Runs an SQL script (read in using the Reader parameter)void
setDelimiter(String delimiter, boolean fullLineDelimiter)
void
setErrorLogWriter(PrintWriter errorLogWriter)
Setter for errorLogWriter propertyvoid
setFinalResultSet(ResultSet finalResultSet)
void
setHasResults(boolean hasResults)
void
setLogWriter(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- Parameters:
connection
- the connectionautoCommit
- the auto commitstopOnError
- the stop on error
-
-
Method Detail
-
isHasResults
public boolean isHasResults()
-
setHasResults
public void setHasResults(boolean hasResults)
-
getFinalResultSet
public ResultSet getFinalResultSet()
-
setFinalResultSet
public void setFinalResultSet(ResultSet finalResultSet)
-
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(Reader reader) throws IOException, SQLException
Runs an SQL script (read in using the Reader parameter)- Parameters:
reader
- - the source of the script- Throws:
IOException
- the io exceptionSQLException
- the sql exception
-
-