Package org.h2.tools
Class Shell
java.lang.Object
org.h2.util.Tool
org.h2.tools.Shell
- All Implemented Interfaces:
Runnable
Interactive command line tool to access a database using JDBC.
-
Field Summary
Fields inherited from class org.h2.util.Tool
out
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Options are case sensitive.protected void
Print the string without newline, and flush.void
run()
INTERNAL.void
Run the shell tool with the given command line settings.void
runTool
(Connection conn, String... args) Run the shell tool with the given connection and command line settings.void
setErr
(PrintStream err) Sets the standard error stream.void
setIn
(InputStream in) Redirects the standard input.void
setInReader
(BufferedReader reader) Redirects the standard input.Methods inherited from class org.h2.util.Tool
getMainClassName, isOption, printNoDatabaseFilesFound, setOut, showUsage, showUsageAndThrowUnsupportedOption, throwUnsupportedOption
-
Constructor Details
-
Shell
public Shell()
-
-
Method Details
-
main
Options are case sensitive.Supported options [-help] or [-?] Print the list of options [-url "<url>"] The database URL (jdbc:h2:...) [-user <user>] The user name [-password <pwd>] The password [-driver <class>] The JDBC driver class to use (not required in most cases) [-sql "<statements>"] Execute the SQL statements and exit [-properties "<dir>"] Load the server properties from this directory - Parameters:
args
- the command line arguments- Throws:
SQLException
- on failure
-
setErr
Sets the standard error stream.- Parameters:
err
- the new standard error stream
-
setIn
Redirects the standard input. By default, System.in is used.- Parameters:
in
- the input stream to use
-
setInReader
Redirects the standard input. By default, System.in is used.- Parameters:
reader
- the input stream reader to use
-
runTool
Run the shell tool with the given command line settings.- Specified by:
runTool
in classorg.h2.util.Tool
- Parameters:
args
- the command line settings- Throws:
SQLException
- on failure
-
runTool
Run the shell tool with the given connection and command line settings. The connection will be closed when the shell exits. This is primary used to integrate the Shell into another application.Note: using the "-url" option in
args
doesn't make much sense since it will override theconn
parameter.- Parameters:
conn
- the connectionargs
- the command line settings- Throws:
SQLException
- on failure
-
print
Print the string without newline, and flush.- Parameters:
s
- the string to print
-
run
public void run()INTERNAL. Hides the password by repeatedly printing backspace, backspace, >, <.
-