|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.spy.SpyObject
net.spy.db.SQLRunner
public class SQLRunner
Run a SQL script from an InputStream.
SQL scripts run by this class are slightly special over normal SQL scripts in that they require a particular structure.
Lines beginning with a SQL comment (--) are logged at info level. Queries are executed when a semicolon is encountered on a line all by itself. Empty lines are ignored. Everything else is concatenated to form the next query to execute. Queries that return a result set will throw a SQLException.
| Constructor Summary | |
|---|---|
SQLRunner(java.sql.Connection conn)
Get an instance of SQLRunner. |
|
| Method Summary | |
|---|---|
void |
runScript(java.io.InputStream is)
Run the given script as a transaction. |
void |
runScript(java.io.InputStream is,
boolean autocommit,
boolean errok)
Run the given script. |
void |
setTimeout(int to)
Set the query timeout (in seconds). |
| Methods inherited from class net.spy.SpyObject |
|---|
getLogger |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SQLRunner(java.sql.Connection conn)
| Method Detail |
|---|
public void setTimeout(int to)
public void runScript(java.io.InputStream is)
throws java.sql.SQLException,
java.io.IOException
is - the stream containing the script
java.sql.SQLException - if there's a SQL problem with this script
java.io.IOException - if there's a problem reading the script
public void runScript(java.io.InputStream is,
boolean autocommit,
boolean errok)
throws java.sql.SQLException,
java.io.IOException
is - the stream containing the scriptautocommit - if true, commit after each statementerrok - if true, ignore SQL exceptions on each statement
java.sql.SQLException - if there's a SQL problem executing the script
java.io.IOException - if there's a problem reading the script
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||