Jisql - a Java based interactive SQL application

Jisql is a Java based utility to provide a command line interactive session with a SQL server. This application is conceptually modeled on the Sybase 'isql' program with, obviously, strong similarities to Microsoft SQL/Server isql and osql (as Microsoft got SQL Server from Sybase).

The program can act in a similar way to Oracle's sqlplus and PostgreSQL's psql.

The complete Jisql package (source code, Javadoc, build environment) can be downloaded from:

Windows users: There seem to be problems with WinZip and the tar.gz version of the archive if you open it directly without saving it to disk. The zip version works just fine.

About Java versions: These files have been compiled with Java 6. There is now a call to a Java 1.6 only class (the Console class) that forces you to use Java 1.6 and above. However, a pretty simple change in Jisql.java would remove this dependency. Since any Java version below 1.6 is no longer supported by Oracle I figured that this would be ok.

These files contain a precompiled jar file along with all of the source code and an ant build file.

A simple command line might look like (this should be all on one line) is:
java -cp lib/jisql-2.0.11.jar:lib/jopt-simple-3.2.jar: <jar for native driver> com.xigole.util.sql.Jisql -user scott -password blah -driver postgresql -cstring jdbc:postgresql://localhost:5432/scott -c \;

This logs into a PostgreSQL database as the user "scott", password "blah". It connects to the database named "scott". It uses the command terminator of ";", just like psql or sqlplus (which is escaped in the example so that it will not be interpreted by the Unix shell). If you do not use this the default is the term "go" on a single line like Sybase's isql or MS/SQL's isql/osql. Note that this command line sample does not use the included javacsv.jar so you could only use the XML or default output formatter (see below for more information).

New in version 2.0.x
The biggest change in version 2 is the addition of separate output formatters. Basically this allows you to more easily customize the output for your application. There are three formatters that are included with the distribution:

  1. Default (does not have to be specified on the command line). This is the default formatter and it behaves like a "normal" format command line interface. Output is wrapped in "pretty" formatters (a highly subjective term). If you've used a database command line tool then this format will very likely feel familar.
  2. CSV The output follows a Comma Separated Values format. The default separator is a comma but any other character can be used. I like using the pipe character as it makes parsing the output very easy.
  3. XML The output is a very simple XML tree. Basically there is the normal XML processing instruction at the top and then every row is output with the column names.

There is now a dependency on JOpt Simple in for the base configuration. Additionally, if you are using the CSVFormatter then it is dependent on Java CSV.

New in version 2.0.5
There is a bit better versioning information available. The jar has been renamed to include the version so that you can quickly see what you're running. This same version information is included in the code (run with -help or with no arguments to see the version) and in the jar manifest.

Options:

 

The included default formatter supports the following command line options:

 

The include CSV formatter supports the following command line options:

 

The included XML formatter does not have any additional output options.

 

New! - if you're having any issues with jisql, come and discuss it in our forums.

Copyright (C) 2004-2011 Scott Dunbar (scott@xigole.com)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

<% response.setDateHeader( "Last-Modified", new java.text.SimpleDateFormat( "MMM dd, yyyy 'at' HH:mm:ss aa zzz" ).parse( "Sep 07, 2011 at 09:46:07 AM MDT", new java.text.ParsePosition(0) ).getTime() ); %>