Keywords: Hsqldb, Database, Manager

| Chapter 3. Database Manager |
Chapter 2. Hsqldb Test Utility |  | Chapter 4. Transfer Tool

# Chapter 3. Database Manager

### Fred Toussi

The HSQL Development Group

### Blaine Simpson

The HSQL Development Group

$Revision: 6065 $

2020-06-29

## Brief Introduction

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. The SWING version has more refinements than the AWT version.

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.

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 labelled 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.

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.

Most SWING 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 Help menu.

The database object tree in the SWING version allows you to right click on the name of a table or column and choose from common SQL statements for the object, for example SELECT * FROM thistable ... If you click on one of the given choices, the sample statement is copied to the command window, where you can modify and complete it.

The DatabaseManagers do work with HSQLDB servers serving TLS-encrypted JDBC data. See the TLS section of the Listeners chapter of the HyperSQL User Guide

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

## Auto tree-update

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 view / Auto-refresh tree menu item to turn it off. You will then need to use the viewRefresh tree menu item every time that you want to refresh the tree.

| Note
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).

## Automatic Connection

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.

        java org.hsqldb.util.DatabaseManagerSwing --help

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

| Warning
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.

## RC File

You can skip the connection dialog window securely by putting the connection information into an RC file and then using the `--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.

The default location for the RC file is `dbmanager.rc` in your home directory. The RC File Authentication Setup section explains how to put the connection information into this text file. If you also run SqlTool, 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 `--rcfile` switch for either SqlTool or DatabaseManagerSwing.

| Warning
Use your operating system facilities to prevent others from reading your RC file, since it contains passwords.

To set up launch items/icons, first experiment on your command line to find exactly what command works. For example,

    java -cp /path/to/hsqldb.jar org.hsqldb.util.DatabaseManagerSwing --urlid mem

Then, use your window manager to add an item that runs this command.

## Using the current DatabaseManagers with an older HSQLDB distribution.

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.

These instructions assume that you are capable of running an Ant build. See the Building Appendix of the HyperSQL User Guide.

1. 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.

2. Cd to the build directory under the root directory where you extracted the distribution to.

3. Run `ant hsqldbutil`.

4. If you're going to wipe out the build directory, copy `hsqldbutil.jar` to a safe location first.

5. For now on, whenever you are going to run DatabaseManager*, make sure that you have this `hsqldbutil.jar` as the first item in your `CLASSPATH`.

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.

    CLASSPATH=/path/to/hsqldbutil.jar:/home/bob/myapp/classes:/usr/local/lib/pg.jdbc3.jar
    export CLASSPATH
    java org.hsqldb.util.DatabaseManagerSwing --urlid urlid

## DatabaseManagerSwing as an Applet

DatabaseManagerSwing up to version 2.4.x is also an applet (from 2.5.0 applet support is no longer available). 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 fail.

Since the Applet can not store or load locally saved preferences, the only way to have persistent preference settings is by using Applet parameters.

DatabaseManagerSwing Applet Parameters

jdbcUrl | URL of a data source to auto-connect to. String value.
jdbcDriver | URL of a data source to auto-connect to. String value. Defaults to `org.hsqldb.driver.JDBCDriver`.
jdbcUser | User name for data source to auto-connect to. String value.
jdbcPassword | Password for data source to auto-connect to. String value. Defaults to zero-length string.
schemaFilter | Display only object from this schema in the object navigator. String value.
laf | Look-and-feel. String value.
loadSampleData | Auto-load sample data. Boolean value. Defaults to false.
autoRefresh | Auto-refresh the object navigator when DDL modifications detected in user SQL commands. Boolean value. Defaults to true.
showRowCounts | Show number of rows in each table in the object navigator. Boolean value. Defaults to false.
showSysTables | Show system tables in the object navigator. Boolean value. Defaults to false.
showSchemas | Show object names like schema.name in object navigator. Boolean value. Defaults to true.
resultGrid | Show query results in Gui grid (as opposed to in plain text). Boolean value. Defaults to true.
showToolTips | Show help hover-text. Boolean value. Defaults to true.

$Revision: 6065 $

Chapter 2. Hsqldb Test Utility |  | Chapter 4. Transfer Tool