com.ibatis.common.jdbc
Class ScriptRunner

java.lang.Object
  extended bycom.ibatis.common.jdbc.ScriptRunner

public class ScriptRunner
extends java.lang.Object

Tool to run database scripts


Field Summary
private  boolean autoCommit
           
private  java.lang.String driver
           
private  java.io.PrintWriter errorLogWriter
           
private  java.io.PrintWriter logWriter
           
private  java.lang.String password
           
private  boolean stopOnError
           
private  java.lang.String url
           
private  java.lang.String username
           
 
Constructor Summary
ScriptRunner()
          Default constructor
ScriptRunner(java.util.Map props)
          Constructor to allow passing in a Map with configuration data
 
Method Summary
private  void flush()
           
 java.lang.String getDriver()
          Getter for driver property
 java.io.PrintWriter getErrorLogWriter()
          Getter for errorLogWriter property
 java.io.PrintWriter getLogWriter()
          Getter for logWriter property
 java.lang.String getPassword()
          Getter for password property
 java.lang.String getUrl()
          Getter for url property
 java.lang.String getUsername()
          Getter for username property
 boolean isAutoCommit()
          Getter for autoCommit property
 boolean isStopOnError()
          Getter for stopOnError property
private  void print(java.lang.Object o)
           
private  void println(java.lang.Object o)
           
private  void printlnError(java.lang.Object o)
           
 void runScript(java.sql.Connection conn, java.io.Reader reader)
          Runs an SQL script (read in using the Reader parameter) using the connection passed in
 void runScript(java.io.Reader reader)
          Runs an SQL script (read in using the Reader parameter)
 void setAutoCommit(boolean autoCommit)
          Setter for autoCommit property
 void setDriver(java.lang.String driver)
          Setter for driver property
 void setErrorLogWriter(java.io.PrintWriter errorLogWriter)
          Setter for errorLogWriter property
 void setLogWriter(java.io.PrintWriter logWriter)
          Setter for logWriter property
 void setPassword(java.lang.String password)
          Setter for password property
 void setStopOnError(boolean stopOnError)
          Setter for stopOnError property
 void setUrl(java.lang.String url)
          Setter for url property
 void setUsername(java.lang.String username)
          Setter for username property
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

driver

private java.lang.String driver

url

private java.lang.String url

username

private java.lang.String username

password

private java.lang.String password

stopOnError

private boolean stopOnError

autoCommit

private boolean autoCommit

logWriter

private java.io.PrintWriter logWriter

errorLogWriter

private java.io.PrintWriter errorLogWriter
Constructor Detail

ScriptRunner

public ScriptRunner()
Default constructor


ScriptRunner

public ScriptRunner(java.util.Map props)
Constructor to allow passing in a Map with configuration data

Parameters:
props - - the configuration properties
Method Detail

isStopOnError

public boolean isStopOnError()
Getter for stopOnError property

Returns:
The value of the stopOnError property

setStopOnError

public void setStopOnError(boolean stopOnError)
Setter for stopOnError property

Parameters:
stopOnError - - the new value of the stopOnError property

isAutoCommit

public boolean isAutoCommit()
Getter for autoCommit property

Returns:
The value of the autoCommit property

setAutoCommit

public void setAutoCommit(boolean autoCommit)
Setter for autoCommit property

Parameters:
autoCommit - - the new value of the autoCommit property

getLogWriter

public java.io.PrintWriter getLogWriter()
Getter for logWriter property

Returns:
The value of the logWriter property

setLogWriter

public void setLogWriter(java.io.PrintWriter logWriter)
Setter for logWriter property

Parameters:
logWriter - - the new value of the logWriter property

getErrorLogWriter

public java.io.PrintWriter getErrorLogWriter()
Getter for errorLogWriter property

Returns:
The value of the errorLogWriter property

setErrorLogWriter

public void setErrorLogWriter(java.io.PrintWriter errorLogWriter)
Setter for errorLogWriter property

Parameters:
errorLogWriter - - the new value of the errorLogWriter property

getDriver

public java.lang.String getDriver()
Getter for driver property

Returns:
The value of the driver property

setDriver

public void setDriver(java.lang.String driver)
Setter for driver property

Parameters:
driver - - the new value of the driver property

getUrl

public java.lang.String getUrl()
Getter for url property

Returns:
The value of the url property

setUrl

public void setUrl(java.lang.String url)
Setter for url property

Parameters:
url - - the new value of the url property

getUsername

public java.lang.String getUsername()
Getter for username property

Returns:
The value of the username property

setUsername

public void setUsername(java.lang.String username)
Setter for username property

Parameters:
username - - the new value of the username property

getPassword

public java.lang.String getPassword()
Getter for password property

Returns:
The value of the password property

setPassword

public void setPassword(java.lang.String password)
Setter for password property

Parameters:
password - - the new value of the password property

runScript

public void runScript(java.io.Reader reader)
               throws java.lang.ClassNotFoundException,
                      java.sql.SQLException,
                      java.io.IOException,
                      java.lang.IllegalAccessException,
                      java.lang.InstantiationException
Runs an SQL script (read in using the Reader parameter)

Parameters:
reader - - the source of the script
Throws:
java.lang.ClassNotFoundException - if the driver class cannot be found
java.sql.SQLException - if any SQL errors occur
java.io.IOException - if there is an error reading from the Reader
java.lang.IllegalAccessException - if there are problems creating the driver class
java.lang.InstantiationException - if there are problems creating the driver class

runScript

public void runScript(java.sql.Connection conn,
                      java.io.Reader reader)
               throws java.io.IOException,
                      java.sql.SQLException
Runs an SQL script (read in using the Reader parameter) using the connection passed in

Parameters:
conn - - the connection to use for the script
reader - - the source of the script
Throws:
java.sql.SQLException - if any SQL errors occur
java.io.IOException - if there is an error reading from the Reader

print

private void print(java.lang.Object o)

println

private void println(java.lang.Object o)

printlnError

private void printlnError(java.lang.Object o)

flush

private void flush()