This example HSQLDB source code file (dbmanager.xml) is included in the DevDaily.com
"Java Source Code
Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: dbmanager.xml,v 1.12 2005/07/25 23:21:10 unsaved Exp $ -->
<appendix>
<title>Database Manager
<appendixinfo>
<authorgroup>
<author>
<firstname>Fred
<surname>Toussi
<affiliation>
<orgname>HSQLDB Development Group
</affiliation>
<email>ft@cluedup.com
</author>
<author>
<firstname>Blaine
<surname>Simpson
<affiliation>
<orgname>HSQLDB Development Group
</affiliation>
<email>ft@cluedup.com
</author>
</authorgroup>
<edition>$Revision: 1.12 $
<pubdate>$Date: 2005/07/25 23:21:10 $
<keywordset>
<keyword>Hsqldb
<keyword>Database
<keyword>Manager
</keywordset>
</appendixinfo>
<section>
<title>Brief Introduction
<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 menu.
<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
and <guimenuitem>Show row counts are both off
<emphasis>before connecting to the database.
You may also want to turn off Auto tree-update, as described in
the next section.
</tip>
</section>
<section>
<title>Auto tree-update
<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 /
<guimenuitem>Auto-refresh tree menu item to turn it off. You
will then need to use the <guimenu>viewRefresh
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
<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>
<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
<simpara>You can skip the connection dialog window securely by putting the
connection information into an RC file and then using the
<literal>--urlid 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 in your home directory. The 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 ant hsqldbutil.
</step>
<step>
<simpara>If you're going to wipe out the build directory, copy
<filename>hsqldbutil.jar 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 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>
</section>
<section>
<title>DatabaseManagerSwing as an Applet
<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>DatabaseManagerSwing Applet Parameters
<varlistentry>jdbcUrl
URL of a data source to auto-connect to. String value.
</simpara>
<varlistentry>jdbcDriver
URL of a data source to auto-connect to. String value.
Defaults to <literal>org.hsqldb.jdbcDriver.
</simpara>
<varlistentry>jdbcUser
User name for data source to auto-connect to. String value.
</simpara>
<varlistentry>jdbcPassword
Password for data source to auto-connect to. String value.
Defaults to zero-length string.
</simpara>
<varlistentry>schemaFilter
Display only object from this schema in the object navigator.
String value.
</simpara>
<varlistentry>laf
Look-and-feel. String value.
</simpara>
<varlistentry>loadSampleData
Auto-load sample data. Boolean value.
Defaults to false.
</simpara>
<varlistentry>autoRefresh
Auto-refresh the object navigator when DDL modifications
detected in user SQL commands. Boolean value.
Defaults to true.
</simpara>
<varlistentry>showRowCounts
Show number of rows in each table in the object navigator.
Boolean value. Defaults to false.
</simpara>
<varlistentry>showSysTables
Show system tables in the object navigator. Boolean value.
Defaults to false.
</simpara>
<varlistentry>showSchemas
Show object names like schema.name in object navigator.
Boolean value. Defaults to true.
</simpara>
<varlistentry>resultGrid
Show query results in Gui grid (as opposed to in plain text).
Boolean value. Defaults to true.
</simpara>
<varlistentry>showToolTips
Show help hover-text. Boolean value. Defaults to true.
</simpara>
</variablelist>
</para>
</section>
</appendix>
Other HSQLDB examples (source code examples)
Here is a short list of links related to this HSQLDB dbmanager.xml source code file: