javasqljavadb

How to use JavaDB as SQL parser


About a month ago I built an application that used zSQL as the SQL parser to parse SQL. However, just few days ago, a heavy duty user sent in a multi row insert statement which zSQL doesn't support. This is the sample:

INSERT INTO MyTable (FirstCol, SecondCol)
SELECT 'First' ,1
UNION ALL
SELECT 'Second' ,2
UNION ALL
SELECT 'Third' ,3
UNION ALL
SELECT 'Fourth' ,4
UNION ALL
SELECT 'Fifth' ,5

Then I found this link: http://weblogs.java.net/blog/2008/11/23/stand-alone-sql-parser-java, it says "With a simple fix, Rick Hillegas has ensured that developers can have access to a powerful SQL parser that comes with Apache/Derby". However, I can't find any relevant documentation to achieve this.

Any idea?


Solution

  • Did you try clicking on the link 'a simple fix' in that post on java.net? The first comment shows how to run the tool. If you read the code to ASTParser.java, you can see the code you need to write to use the parser.