Generic Report Writer

A Menu-driven Report Writer in Java


Oct. 8, 1999

This is the release of Generic Report Writer version 1.0


Generic Report Writer is a menu-driven report writer.

Works with PostgreSQL, MySQL, and Access. It probably will work on any other database for which you have a Type 4 JDBC version 1 driver.

Written in Java 1.2 (2.0) and uses Type 4 JDBC version 1 database drivers.

Source code is included. You can run it as is, or just use the processing engine and modify the headers, formatting, and other features to suit yourself.

Has two modes. INTERACTIVE means a user is present and is designing or running a report. AUTOMATIC means run the report from a batch file, cron job, or servlet. (I haven't used it yet from a servlet.)

GRW saves the report format to your database for re-use later.

Can do decimal rounding of numbers, order by and group by functions , and group totals and grand totals. Cannot do user-defined functions.

At the moment it outputs only text. Future versions may include the ability to do fonts as well as html, xml, or Postscript output. (Would anyone like to suggest how to let users choose fonts in a menu oriented program?)



Follow the GPL instructions available at GNU's web site.

Installation Instructions

Whether you're using INTERACTIVE or AUTOMATIC mode: You must already have Sun's JDK 1.2 (2.0) installed on your system and it must be in your path.

Put the downloaded .zip file into your chosen directory. Unzip it.

In the database you intend to report from, create a table named GReports to hold the formatting information. Details on how to create the table are given below for each type of database. If you beta tested the first version, drop that GReports table and create this one. Some of the data I store has changed and this GRW won't recognize old format info.


mydb=> create table GReports (GRepName character (50), GRepData varchar (4096),primary key (GRepName));


mysql> create table GReports (GRepName char(50) not null, GRepData TEXT, primary key(GRepName));


Use the menus to create a table named GReports with two fields. GRepName is data type text, length 50. GRepData is data type memo. Make GRepName the primary key. Use the 32-bit ODBC icon in the Control Panel to create an odbc System-DSN connection to your database.

For INTERACTIVE mode: With any of the databases, modify the properties file (*.prp) for the database you intend to talk to. PostgreSQL.prp is for PostgreSQL, MySQL.prp is for MySQL, and Access.prp is for Access. Change the database name, location, user name, etc to match your needs. Any of those can also be typed in by hand once you start the program.

There are sample batch files included to show you how to start GRW for each type of database. DemoPostgreSQL.bat launches it for PostgreSQL, DemoMySQL.bat for MySQL, and DemoAccess.bat for Access.

Notice the classpath statement in PostgreSQL.bat and MySQL.bat. Since those drivers are Java 1.1, the classpath is necessary even though GRW itself is in Java 2. You'll need to know where your jdbc driver is. For PostgreSQL, the driver for version 6.4.2 is included in the download and will be in that directory. For MySQL, on my own office machine, I have the TWZ driver installed under my c:\jdk1.2\bin directory which is already in my DOS environment path. Last Access doesn't need a separate driver since it uses odbc. Sun's odbc/jdbc bridge installs as part of their jdk. You can put your drivers in other places if you want, just change the classpath to say where they are.

If you are not on a Windows machine, transfer the command line from those files to your command line and execute it. Notice the ;. on the end of the classpath for PostgreSQL and MySQL. Also, the \ is only for Windows machines obviously.

At the CONNECT screen you can modify the url etc. if needed before hitting the connect button.

For AUTOMATIC mode: Follow the above instructions except that the sample properties file is AutoAccess.prp and the sample start-up file is DemoAutoAccess.bat. Notice the first line of AutoAccess.prp says mode>automatic. That's how the program knows which way to run. Also, notice it gives the name of the report to generate and directory and file name where you want the output placed.

For either INTERACTIVE or AUTOMATIC mode: Don't try to report on memo, varchar, binary, nor blob fields. It can't handle those yet.

I will warn you this version is fairly slow. So I wouldn't use it on files with more that 1000 or so records. Compiling your own version with a JIT compiler should speed it up quite a bit.

There is little error checking, so don't be surprised if it prints a stacktrace. Just kill it and re-start.

This is my first Java program. I'm open to suggestions and improvements. As a matter fact that's what I want.


You can contact me at

I wrote this because there were no GPL report writers for Linux and web programming--at least I couldn't find any.


Screen Shots