Class SqlTool


  • public class SqlTool
    extends java.lang.Object
    A command-line JDBC SQL tool supporting both interactive and non-interactive usage.

    See JavaDocs for the main method for syntax of how to run from the command-line.

    Programmatic users will usually want to use the objectMain(String[]) method if they want arguments and behavior exactly like command-line SqlTool. But in many cases, you will have better control and efficiency by using the SqlFile class directly. The file src/org/hsqldb/sample/SqlFileEmbedder.java in the HSQLDB distribution provides an example for this latter strategy.

    Author:
    Blaine Simpson (blaine dot simpson at admc dot com)
    See Also:
    The SqlTool chapter of the HyperSQL Utilities Guide, main(String[]), objectMain(String[]), SqlFile
    • Constructor Detail

      • SqlTool

        public SqlTool()
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
        A static wrapper for objectMain, so that that method may be executed as a Java "program".

        Throws only RuntimeExceptions or Errors, because this method is intended to System.exit() for all but disastrous system problems, for which the inconvenience of a stack trace would be the least of your worries.

        If you don't want SqlTool to System.exit(), then use the method objectMain() instead of this method.

        Parameters:
        args - arguments
        See Also:
        objectMain(String[])
      • objectMain

        public static void objectMain​(java.lang.String[] arg)
                               throws SqlTool.SqlToolException
        Connect to a JDBC Database and execute the commands given on stdin or in SQL file(s).

        This method is changed for HSQLDB 1.8.0.8 and later to never System.exit(). Developers may catch Throwables to handle all fatal situations.

        Parameters:
        arg - Run "java... org.hsqldb.cmdline.SqlTool --help" for syntax.
        Throws:
        SqlTool.SqlToolException - Upon any fatal error, with useful reason as the exception's message.