|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.darwinsys.sql.SQLRunner
public class SQLRunner
Class to run an SQL script, like psql(1), SQL*Plus, or similar programs. Command line interface accepts options -c config [-f configFile] [scriptFile].
Input language is: escape commands (begin with \ and MUST end with semi-colon), or standard SQL statements which must also end with semi-colon);
Escape sequences:
This class can also be used from within programs such as servlets, etc.; see SQLRunnerGUI for an example of how to call.
For example, this command and input: SQLrunner -c testdb \ms; select * from person where person_key=4; might produce this output:
Executing : <
TODO: Fix parsing so \\ escapes don't need to end with SQL semi-colon.
Constructor Summary | |
---|---|
SQLRunner(java.sql.Connection c,
java.lang.String outputFile,
java.lang.String outputModeName)
|
|
SQLRunner(java.lang.String driver,
java.lang.String dbUrl,
java.lang.String user,
java.lang.String password,
java.lang.String outputFile,
java.lang.String outputMode)
Construct a SQLRunner object |
Method Summary | |
---|---|
void |
close()
|
static void |
exit(int exitStatus)
|
static java.lang.String |
getStatement(java.io.BufferedReader is)
Extract one statement from the given Reader. |
static Verbosity |
getVerbosity()
|
boolean |
isEscape()
|
static boolean |
isOkToExit()
|
void |
runScript(java.io.BufferedReader is,
java.lang.String name)
Deprecated. |
void |
runScript(java.lang.String scriptFile)
Deprecated. |
void |
runStatement(java.lang.String rawString)
Run one Statement, and format results as per Update or Query. |
void |
setErrorHandler(SQLRunnerErrorHandler eHandler)
|
void |
setGUI(SQLRunnerGUI gui)
|
static void |
setOkToExit(boolean setting)
|
void |
setOutputFile(java.io.PrintWriter writer)
Set the output to the given Writer; immediately update the textDecorator so \dt works... |
void |
setOutputFile(java.lang.String fileName)
Set the output to the given filename. |
static void |
setVerbosity(Verbosity verbosity)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SQLRunner(java.lang.String driver, java.lang.String dbUrl, java.lang.String user, java.lang.String password, java.lang.String outputFile, java.lang.String outputMode) throws java.io.IOException, java.lang.ClassNotFoundException, java.sql.SQLException
driver
- String for the JDBC driverdbUrl
- String for the JDBC URLuser
- String for the usernamepassword
- String for the password, normally in cleartextoutputMode
- One of the MODE_XXX constants.
java.lang.ClassNotFoundException
java.sql.SQLException
java.io.IOException
public SQLRunner(java.sql.Connection c, java.lang.String outputFile, java.lang.String outputModeName) throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
Method Detail |
---|
public static void setOkToExit(boolean setting)
public static boolean isOkToExit()
public static void exit(int exitStatus)
@Deprecated public void runScript(java.lang.String scriptFile) throws java.io.IOException, java.sql.SQLException, SyntaxException
while ((stmt = SQLRunner.getStatement(is)) != null) { stmt = stmt.trim(); try { myRunner.runStatement(stmt); } catch (Exception e) { // Display the message to the user ... } }
SyntaxException
java.io.IOException
java.sql.SQLException
@Deprecated public void runScript(java.io.BufferedReader is, java.lang.String name) throws java.io.IOException, java.sql.SQLException, SyntaxException
while ((stmt = SQLRunner.getStatement(is)) != null) { stmt = stmt.trim(); try { myRunner.runStatement(stmt); } catch (Exception e) { // Display the message to the user ... } }
SyntaxException
java.io.IOException
java.sql.SQLException
public void setOutputFile(java.lang.String fileName) throws java.io.IOException
fileName
-
java.io.IOException
public void setOutputFile(java.io.PrintWriter writer)
writer
- public void runStatement(java.lang.String rawString) throws java.io.IOException, java.sql.SQLException, SyntaxException
SyntaxException
java.io.IOException
java.sql.SQLException
public static java.lang.String getStatement(java.io.BufferedReader is) throws java.io.IOException
java.io.IOException
public void close() throws java.sql.SQLException
java.sql.SQLException
public static Verbosity getVerbosity()
public static void setVerbosity(Verbosity verbosity)
public void setErrorHandler(SQLRunnerErrorHandler eHandler)
public void setGUI(SQLRunnerGUI gui)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isEscape()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |