com.xigole.util.sql
Class Jisql

java.lang.Object
  extended by com.xigole.util.sql.Jisql

public class Jisql
extends java.lang.Object

A simple utility to provide an 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.

A simple command line might look like (this should be all on one line) is:
java -classpath lib/jisql.jar:<file containing 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 there is a dependency on JOpt Simple in for the base configuration. Additionally, if you are using the CSVFormatter then it is dependent on Java CSV.

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.

 

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.


Constructor Summary
Jisql()
           
 
Method Summary
 void doIsql()
          The main loop for the Jisql program.
static void main(java.lang.String[] argv)
          Runs Jisql with the command line arguments provided.
 void parseArgs(java.lang.String[] argv)
          Parse the command line arguments.
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Jisql

public Jisql()
Method Detail

main

public static void main(java.lang.String[] argv)
Runs Jisql with the command line arguments provided.


run

public void run()
         throws java.lang.Exception
Throws:
java.lang.Exception

doIsql

public void doIsql()
            throws java.sql.SQLException
The main loop for the Jisql program. This method handles the input from either a command line or from a file. Output is handled through the Formatter.

Throws:
java.sql.SQLException - if an exception occurs.

parseArgs

public void parseArgs(java.lang.String[] argv)
               throws java.lang.Throwable
Parse the command line arguments. This method parses what is needed for the Jisql driver program and lets the configured formatter do the same.

Parameters:
argv - the command line arguments.
Throws:
java.lang.Exception - if there are any errors parsing the command line arguments.
java.lang.Throwable