General SQL Parser Java Version 0.1

I’m very excited to let you know that General SQL Parser Java Version 0.1 was finally released in 01-22-2010. This is the first release of general sql parser java version.

This SQL parser had a solid infrastructure now, with the ability to parse most SQL statements used in Access, SQL Server, DB2, MySQL and Oracle, including nested queries, complex join clause, stored procedure, trigger, function, PLSQL packages and etc. Syntax check is the most basic feature which is available once I finished the infrastructure of this SQL parser. But I’m too busy to add more features like  SQL formatter, fetch table and column information of SQL statement, modify and rebuild SQL, query tree structure in xml(Those features are already available in .NET and VCL version).  So SQL syntax check is the main feature of this release, and I will add more features(some may not listed above) one by one based on requests from users. If you want to use this SQL parser in your project or product, please don’t hesitate to contact me(info@sqlparser.com) for further information about this SQL parser.

Ok, Here are some detailed information about this release.

All supported SQL statements are listed in those packages:

gudusoft.gsqlparser.stmt

gudusoft.gsqlparser.stmt.db2

gudusoft.gsqlparser.stmt.mysql

gudusoft.gsqlparser.stmt.mssql

gudusoft.gsqlparser.stmt.oracle

This SQL Parser can be used in several ways such as:

1. Check SQL syntax of Access, Db2, MySQL, SQL Server, Oracle dialect. Give detailed error message if found any syntax error in SQL script.

2. Get all SQL statements with type and fragment information in SQL script.

select last_name,job_id,salary from employees
where job_id=(select job_id
from employees
where employee_id=141)
and salary >
(select salary
from employees
where employee_id=141);

insert into emp e1 (e1.lastname,job) values(scott,10);

delete from department
where department_name = ‘Finance’;

update employees
set job_id = (select job_id
from employees
where employee_id = 205),
salary = (select salary from employees
where employee_id = 205)
where employee_id = 114;

SQL parser can analyze this script, and list 4 individual statement like this:

sstselect
=========
select last_name,job_id,salary from employees
where job_id=(select job_id
from employees
where employee_id=141)
and salary >
(select salary
from employees
where employee_id=141);

sstinsert
=========
insert into emp e1 (e1.lastname,job) values(scott,10);

sstdelete
=========
delete from department
where department_name = ‘Finance’;

sstupdate
=========
update employees
set job_id = (select job_id
from employees
where employee_id = 205),
salary = (select salary from employees
where employee_id = 205)
where employee_id = 114;

3. Tokenize SQL script, easy to check identifier, keyword, operator, constants, comment and special characters.

insert into emp e1 (e1.lastname,job) values(scott,10);

After tokenize this script, SQL parser will generate output like this:

ttkeyword insert
ttwhitespace
ttkeyword into
ttwhitespace
ttidentifier emp
ttwhitespace
ttidentifier e1
ttwhitespace
ttleftparenthesis (
ttidentifier e1
ttperiod .
ttidentifier lastname
ttcomma ,
ttidentifier job
ttrightparenthesis )
ttwhitespace
ttkeyword values
ttleftparenthesis (
ttidentifier scott
ttcomma ,
ttnumber 10
ttrightparenthesis )
ttsemicolon ;

If you like to have a try of this library, you can download it here:

http://www.sqlparser.com/download.php

What kind of  features will be  in next release?

I will like to add feature to fetch table and column in select/delete/insert/update statement in next release, hopefully, this feature will be available in the end of Feb 2010.

If you have any suggestions or features request about next release, feel free to contact me(info@sqlparser.com), your feedback is always welcome.

Newsletter Updates

Enter your email address below to subscribe to our newsletter