Parent: HintsAndTips

Introduction

DERBY-1447 is a request for enhancement of Derby's IJ tool, adding a command line history.

Until this feature is implemented in IJ, users on some platforms/shells need to employ workarounds in order to enjoy IJ with a command history and other convenient command editing capabilities. This page is intended to describe such workarounds.

With a full Derby installation/build, you can start IJ by running for example the following command on the command line:

java -jar lib/derbyrun.jar ij

Microsoft Windows command windows (cdm.exe and friends) seem to provide native command history and editing features automatically when running ij from the command line.

On Unix/Linux systems, workarounds are usually needed.

Workarounds

Using jEdit

Relatively new versions of jEdit support the Console plugin, which allows you to run shell command in jEdit's environment. This plugin provides a command history and other features when running IJ from the console.

  1. Download, install and start a recent version of jEdit.

  2. On the jEdit menu, go to Plugins --> Plugin Manager.

  3. Select the Install tab.

  4. Select the Console plugin and Install

  5. Restart jEdit if necessary
  6. Start the console via Plugins --> Console --> Console

  7. Start IJ as you would do in a regular terminal window.

You can select previous and next commands using up and down arrows. To move within a command, use (for instance) side arrows.

Using JLine

You can script starting IJ with JLine like this:

java -classpath jline.jar:${IJ_CLASSPATH} ${IJ_OPTIONS} jline.ConsoleRunner org.apache.derby.tools.ij [$@]

Use an alias or a script to ease the startup. Depending on how you do it in your shell, the $@ might not be required to be able to pass arguments to IJ. Modify IJ_CLASSPATH to specify which Derby version / code base to use. If you want to start IJ with certain options, add them to IJ_OPTIONS (these have to be Java properties, for instance -Dij.exceptionTrace=true).

Note that JLine has problems dealing with commands longer than one line in your terminal.

Using Emacs

ij works pretty well in shell-mode and comint-mode, but the best is a custom-designed SQLi-mode. Then you may utilize the sql-send-commands in SQL-mode. I once implemented such a file, feel free to use it, and you find it here: ij.el.

You may wish to define sql-derby-home and sql-ij-classpath in your .emacs file, e.g. like this:

(defvar sql-ij-classpath "/usr/local/share/java/derby/lib/derbytools.jar:/usr/local/share/java/derby/lib/derby.jar:/usr/local/share/java/derby/lib/derbyclient.jar")
(defvar sql-derby-home "/var/tmp/myderbyhome")
(load-file "ij.el")

CommandHistoryInIj (last edited 2009-12-03 21:58:55 by BerntJohnsen)