<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: dbmanager.xml,v 1.13 2006/07/27 21:08:21 fredt Exp $ -->
<appendix>
  <title>Database Manager</title>

  <appendixinfo>
    <authorgroup>
      <author>
        <firstname>Fred</firstname>

        <surname>Toussi</surname>

        <affiliation>
          <orgname>HSQLDB Development Group</orgname>
        </affiliation>

        <email>ft@cluedup.com</email>
      </author>

      <author>
        <firstname>Blaine</firstname>

        <surname>Simpson</surname>

        <affiliation>
          <orgname>HSQLDB Development Group</orgname>
        </affiliation>

        <email>ft@cluedup.com</email>
      </author>
    </authorgroup>

    <edition>$Revision: 1.13 $</edition>

    <pubdate>$Date: 2006/07/27 21:08:21 $</pubdate>

    <keywordset>
      <keyword>Hsqldb</keyword>

      <keyword>Database</keyword>

      <keyword>Manager</keyword>
    </keywordset>
  </appendixinfo>

  <section>
    <title>Brief Introduction</title>

    <para>The Database Manager tool is a simple GUI database query tool with a
    tree display of the tables. Both AWT and SWING versions of the tool are
    available and work almost identically. The AWT version class name is
    org.hsqldb.util.DatabaseManager; the SWING version,
    org.hsqldb.util.DatabaseManagerSwing.</para>

    <para>The AWT version of the database manager can be deployed as an applet
    in a browser. A demo HTML file with an embedded Database Manager is
    included in the /demo directory.</para>

    <para>When the Database Manager is started, a dialogue allows you to enter
    the JDBC driver, URL, user and password for the new connection. A
    drop-down box, Type, offers preset values for JDBC driver and URL for most
    popular database engines, including HSQLDB. Once you have selected an item
    from this drop-down box, you should edit the URL to specify the details of
    the database or any additional properties to pass. You should also enter
    the username and password before clicking on the OK button.</para>

    <para>The connection dialogue allows you to save the settings for the
    connection you are about to make. You can then access the connection in
    future sessions. To save a connection setting, enter a name in the Setting
    Name box before clicking on the OK button. Next time the connection
    dialogue is displayed, the drop-down box labeled Recent will include the
    name for all the saved connection settings. When you select a name, the
    individual settings are displayed in the appropriate boxes.</para>

    <para>The small Clr button next to the drop-down box allows you to clear
    all the saved settings. If you want to modify an existing setting, first
    select it from the drop-down box then modify any of the text boxes before
    making the connection. The modified values will be saved.</para>

    <simpara>Most menu items have context-sensitive tool tip help text which
    will appear if you hold the mouse cursor still over the desired menu item.
    (Assuming that you don't turn Tooltips off under the
    <guimenu>Help</guimenu> menu.</simpara>

    <simpara>The DatabaseManagers do work with HSQLDB servers serving
    TLS-encrypted JDBC data. See the <link endterm="tls-title"
    linkend="tls-chapter" /> chapter and the <link endterm="auth-title"
    linkend="auth-section" /> section of this Guide.</simpara>

    <tip>
        If you are using DatabaseManagerSwing with Oracle, you will want
        to make sure that <guimenuitem>Show row counts</guimenuitem>
        and <guimenuitem>Show row counts</guimenuitem> are both off
        <emphasis>before connecting to the database</emphasis>.
        You may also want to turn off Auto tree-update, as described in
        the next section.
    </tip>
  </section>

  <section>
    <title>Auto tree-update</title>

    <simpara>By default, the object tree in the left panel is refreshed when
    you execute DDL which may update those objects. If you are on a slow
    network or performance-challenged PC, use the <guimenu>view</guimenu> /
    <guimenuitem>Auto-refresh tree</guimenuitem> menu item to turn it off. You
    will then need to use the <guimenu>view</guimenu><guimenuitem>Refresh
    tree</guimenuitem> menu item every time that you want to refresh the
    tree.</simpara>

    <note>
      <simpara>Auto-refresh tree does not automatically show all updates to
      database objects, it only refreshes when you submit DDL which may update
      database objects. (This behavior is a compromise between utility and
      performance).</simpara>
    </note>
  </section>

  <section>
    <title>Automatic Connection</title>

    <para>You can use command-line switches to supply connection information.
    If you use these switch(es), then the connection dialog window will be
    skipped and a JDBC connection will be established immediately. Assuming
    that the hsqldb.jar (or an alternative jar) are in your CLASSPATH, this
    command will list the available command-line options. <informalexample>
        <screen>
    java org.hsqldb.util.DatabaseManagerSwing --help</screen>
      </informalexample></para>

    <simpara>It's convenient to skip the connection dialog window if you
    always work with the same database account.</simpara>

    <warning>
      <simpara>Use of the --password switch is not secure. Everything typed on
      command-lines is generally available to other users on the computer. The
      problem is compounded if you use a network connection to obtain your
      command line. The RC File section explains how you can set up automatic
      connections without supplying a password on the command line.</simpara>
    </warning>
  </section>

  <section>
    <title>RC File</title>

    <simpara>You can skip the connection dialog window securely by putting the
    connection information into an RC file and then using the
    <literal>--urlid</literal> switch to DatabaseManager or
    DatabaseManagerSwing. This strategy is great for adding launch menu items
    and/or launch icons to your desktop. You can set up one icon for each of
    the database accounts which you regularly use.</simpara>

    <simpara>The default location for the RC file is
    <filename>dbmanager.rc</filename> in your home directory. The <link
    endterm="auth-title" linkend="auth-section" /> section explains how to put
    the connection information into this text file. If you also run <link
    endterm="sqltool-title" linkend="sqltool-chapter" />, then you can share
    the RC file with SqlTool by using a sym-link (if your operating system
    supports sym links), or by using the <literal>--rcfile</literal> switch
    for either SqlTool or DatabaseManagerSwing.</simpara>

    <warning>
      <simpara>Use your operating system facilities to prevent others from
      reading your RC file, since it contains passwords.</simpara>
    </warning>

    <para>To set up launch items/icons, first experiment on your command line
    to find exactly what command works. For example, <informalexample>
        <screen>
    java -cp /path/to/hsqldb.jar org.hsqldb.util.DatabaseManagerSwing --urlid mem</screen>
      </informalexample> Then, use your window manager to add an item that
    runs this command.</para>
  </section>

  <section>
    <title>Using the current DatabaseManagers with an older HSQLDB
    distribution.</title>

    <simpara>This procedure will allow users of a legacy version of HSQLDB to
    use all of the new features of the DatabaseManagers. You will also get the
    new version of the SqlTool! This procedure works for distros going back to
    1.7.3.3 at least, probably much farther.</simpara>

    <simpara>These instructions assume that you are capable of running an Ant
    build. See the <link endterm="building-title"
    linkend="building-appendix" /> chapter.</simpara>

    <procedure>
      <step>
        <simpara>Download and extract a current HSQLDB distribution. If you
        don't want to use the source code, documentation, etc., you can use a
        temporary directory and remove it afterwards.</simpara>
      </step>

      <step>
        <simpara>Cd to the build directory under the root directory where you
        extracted the distribution to.</simpara>
      </step>

      <step>
        <simpara>Run <literal>ant hsqldbutil</literal>.</simpara>
      </step>

      <step>
        <simpara>If you're going to wipe out the build directory, copy
        <filename>hsqldbutil.jar</filename> to a safe location
        first.</simpara>
      </step>

      <step>
        <simpara>For now on, whenver you are going to run DatabaseManager*,
        make sure that you have this <filename>hsqldbutil.jar</filename> as
        the first item in your CLASSPATH.</simpara>
      </step>
    </procedure>

    <para>Here's a UNIX example where somebody wants to use the new
    DatabaseManagerSwing with their older HSQLDB database, as well as with
    Postgresql and a local application. <informalexample>
        <screen>
CLASSPATH=/path/to/hsqldbutil.jar:/home/bob/myapp/classes:/usr/local/lib/pg.jdbc3.jar
export CLASSPATH
java org.hsqldb.util.DatabaseManagerSwing --urlid urlid</screen>
      </informalexample></para>
  </section>

  <section>
      <title>DatabaseManagerSwing as an Applet</title>
      <simpara>
          DatabaseManagerSwing is also an applet.
          You can use it in HTML, JSPs, etc.
          Be aware that in Applet mode, actions to load or save local files
          will be disabled, and attempts to access any server other than 
          the HTML-serving-host will be fail.
      </simpara>
      <para>
          Since the Applet can not store or load locally saved preferences,
          the only way to have persistent preference settings is by using
          Applet parameters.
          <variablelist><title>DatabaseManagerSwing Applet Parameters</title>
              <varlistentry><term>jdbcUrl</term><listitem><simpara>
                  URL of a data source to auto-connect to.  String value.
              </simpara></listitem></varlistentry>
              <varlistentry><term>jdbcDriver</term><listitem><simpara>
                  URL of a data source to auto-connect to.  String value.
                  Defaults to <literal>org.hsqldb.jdbcDriver</literal>.
              </simpara></listitem></varlistentry>
              <varlistentry><term>jdbcUser</term><listitem><simpara>
                  User name for data source to auto-connect to.  String value.
              </simpara></listitem></varlistentry>
              <varlistentry><term>jdbcPassword</term><listitem><simpara>
                  Password for data source to auto-connect to.  String value.
                  Defaults to zero-length string.
              </simpara></listitem></varlistentry>
              <varlistentry><term>schemaFilter</term><listitem><simpara>
                  Display only object from this schema in the object navigator.
                  String value.
              </simpara></listitem></varlistentry>
              <varlistentry><term>laf</term><listitem><simpara>
                  Look-and-feel.  String value.
              </simpara></listitem></varlistentry>
              <varlistentry><term>loadSampleData</term><listitem><simpara>
                  Auto-load sample data.  Boolean value.
                  Defaults to false.
              </simpara></listitem></varlistentry>
              <varlistentry><term>autoRefresh</term><listitem><simpara>
                  Auto-refresh the object navigator when DDL modifications
                  detected in user SQL commands.  Boolean value.
                  Defaults to true.
              </simpara></listitem></varlistentry>
              <varlistentry><term>showRowCounts</term><listitem><simpara>
                  Show number of rows in each table in the object navigator.
                  Boolean value.  Defaults to false.
              </simpara></listitem></varlistentry>
              <varlistentry><term>showSysTables</term><listitem><simpara>
                  Show system tables in the object navigator.  Boolean value.
                  Defaults to false.
              </simpara></listitem></varlistentry>
              <varlistentry><term>showSchemas</term><listitem><simpara>
                  Show object names like schema.name in object navigator.
                  Boolean value.  Defaults to true.
              </simpara></listitem></varlistentry>
              <varlistentry><term>resultGrid</term><listitem><simpara>
                  Show query results in Gui grid (as opposed to in plain text).
                  Boolean value.  Defaults to true.
              </simpara></listitem></varlistentry>
              <varlistentry><term>showToolTips</term><listitem><simpara>
                  Show help hover-text.  Boolean value.  Defaults to true.
              </simpara></listitem></varlistentry>
          </variablelist>
      </para>
  </section>
</appendix>
