http://www.quora.com/What-is-the-best-free-commercial-SQL-parser-written-in-Java

I had looked at a lot of free/commercial SQL parsers myself a few months back. There was an interesting discussion at StackOverFlow(http://stackoverflow.com/questio...), though it's quite old. 

  1. Commercial :The best SQLParser which I found was SQLParser( http://www.sqlparser.com/ ) . It is not free but is quite powerful. 
  2. Open Source but unfriendly license for Commercial Products: There were a few open source projects , ZQL http://zql.sourceforge.net/ ) , JSQLPARSER  http://jsqlparser.sourceforge.net/ . These were fine for simple queries but I wouldn't recommend them for complex queries. Another thing with these was that they are quite old projects with no active development in a long while.
  3. Create Your Own : I used this solution to create my own SQLParser using ANTLR(http://www.antlr.org). It has specific parsers for PL/SQL as well as T/SQL. Almost all the ORM frameworks use ANTLR.  You can find the grammar easily but it would require coding efforts.


Have a look at JBoss Teiid(http://www.jboss.org/teiid/) and Hibernate to see how they are doing SQL parsing.

Posted by sjokim
,