Zql: a Java SQL parser


What is Zql ?

Zql is an SQL parser written in Java.
Zql parses SQL and fills in java structures representing SQL statements and expressions.

Zql can parse all the queries given as examples in the following SQL tutorial (a now old version of James Hoffman's SQL tutorial).

See the Zql API documentation for more info about the Zql structures.

An SQL expression evaluator comes with Zql, so you can easily evaluate SQL expressions out of the parser.

Warning: No warranty !

Zql is no commercial product (license: GNU GPLv3). Feel free to use it, but we provide no warranty.
Zql APIs may be subject to changes, to enrich functionalities or fix bugs.

Click here for any bug report or suggestion.

Alternatives to Zql ?

General SQL Parser looks pretty good, with extended SQL syntax (like PL/SQL and T-SQL) and java + .NET APIs.
The tool is commercial (license available online), with a free download option.

How to use Zql ?

First of all, download Zql! (let's say, the latest version).
Then: Some SQL queries for heavy testing...

More details

The parser itself is written with JavaCC, a Java parser generator (like Unix's popular yacc generator).

It takes as input SQL statements (select, insert, update, delete, commit, rollback, set transaction), and fills in Java structures that represent the statements it parsed.

Example:
SELECT ANTIQUEOWNERS.OWNERLASTNAME, ANTIQUEOWNERS.OWNERFIRSTNAME
FROM ANTIQUEOWNERS, ANTIQUES
WHERE ANTIQUES.BUYERID = ANTIQUEOWNERS.OWNERID AND ANTIQUES.ITEM = 'Chair';

Will result in a ZqlQuery structure.
ZqlQuery's getSelect(), getFrom() and getWhere() methods will extract the SELECT, FROM and WHERE parts of the query.

Some history...

The 1st release of SQL came to the net on March 10... 1998 (!).
After a long proprietary life, I finally decided to open the code, in september 2010.
In the meantime, some bugs were fixed and some enhancements added, most of them minor. Note I haven't been working a lot on Zql since the 1st release, and most of the work was finished in late 2002.