Download Latest Version tpc-c-ifmx.tar.gz (392.7 kB)
Email in envelope

Get an email when there's a new version of IIUG Software Repository

Home / JAVA-Tools / jselect
Name Modified Size InfoDownloads / Week
Parent folder
jselect.java 2020-05-11 11.0 kB
jselect.readme 2020-05-11 4.9 kB
Totals: 2 Items   15.9 kB 0
1. Introduction
===============
The program jselect.java provides a user-interface to run SELECT statements
against an Informix database and output the query results in either tabular,
columnar or pipe-delimited format, with or without a header line.

I created this program mainly to use in scripts that access the database,
so I could get the results back in a known format regardless of my SQL. 
This does not happen with dbaccess, since it "intelligently" formats the
output depending on the output width.

However, this script can be used interactively as well. To specify options
that need to be set often, you can reduce typing by specifying a config
file with the --file (or -f) option. The program will read both the config
file, if specified, and the options set from the command line, with the
options on the command line overriding the ones in the file.

2. Environment
==============
To run this program you will need to have java installed as well as the
Informix JDBC driver. I have tested this program with the following 
configuration:

Java Development Kit 1.1.6
Informix JDBC driver 1.40.JC2
Informix Dynamic Server 7.30.UC3
Sun OS 5.5.1

However, as long as your setup has a compatible set of the above softwares,
I dont think you should have any problems with compiling and running the
program.

3. Installation
===============
Prior to compiling and running this, make sure that you have the Java
Development Kit and the Informix JDBC driver installed.

To install the program, make sure you have java and javac in your path.
To figure this out, type the following at your command prompt:

    $ which java
    $ which javac

If it gives you a message like "no java in ...", then you need to set 
your environment variable PATH to point to it.

Check to see if your CLASSPATH is pointing to the ifxjdbc.jar file. This
file contains the Informix JDBC driver. If it is not, you need to set the
CLASSPATH to point to this. Also you need to have CLASSPATH point to the
directory where you will install the class file jselect.class. For example,
if you have installed your JDBC driver in /usr/informix/jdbc and you are
installing the jselect.class file in /home/informix/tools, then your 
CLASSPATH should minimally contain:

	CLASSPATH=/usr/informix/jdbc/lib/ifxjdbc.jar:/home/informix/tools

To compile the jselect.java file, simply run the following command at the
prompt:

    $ javac jselect.java

4. Usage
========
This is how you would call the jselect.class file.

Usage: java jselect [switch=value ...]
Switches:
--host|-h:      Host String in the format hostname:port/database@server,
                where hostname = machine name, port = TCP port-# for instance,
                database = database name, and server = value of INFORMIXSERVER
--auth|-a:      Authentication String in the format username/password,
                where username = Linux login name and password = password
                for the database user.
--style|-s:     Determines the output style. Valid values are col(umnar),
                tab(ular) and pip(e-delimited).
--title|-t:     Determines if titles appear in the output. Valid values
                are yes and no.
--query|-q:     SQL query to be executed. The program does not do any
                syntax checks, but behaves strangely on invalid SELECT syntax
--file|-f:      Full path name of a file that contains the rest of the
                switches in name=value format, just like the command
                line arguments.                                                

You can use either the GNU-style -- "long" options or the regular - "short"
options or a combination of the two. You can specify some or all of the 
switches on the command line or in the file. In the file, however, you
*must* use the long -- form to specify arguments. Here is a sample file,
called jselect.conf, for example:

--host=avalanche:1101/strax@avalanche_soc
--auth=sujit/xxx
--query=SELECT * FROM systables WHERE tabid > 99
--title=yes
--style=tab 

And here is the command line to call jselect with the config file parameters

    java jselect --file=jselect.conf

Here is an example command line call to jselect without the config file:

    java jselect --host=avalanche:1101/strax@avalanche_soc \
      --auth=sujit/xxx --title=yes --style=tab \
      --query="SELECT * FROM systables WHERE tabid > 99"

Out of the switches, the --style and --title are optional. If they are not
specified, then the program defaults them to --style = tab[ular] and 
--title = no. All other switches are mandatory.

5. Copyright and Contact Information
====================================
This program was written by Sujit Pal and is freely distributable under
the conditions of the GNU General Public License. Please mail suggestions 
for improvement or bugs to the author at the following email address: 
sujitpl@ibm.net.
Source: jselect.readme, updated 2020-05-11