Reusable
Reusable

Reputation: 1948

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?

Upvotes: 4

Views: 1685

Answers (2)

user1244215
user1244215

Reputation: 1086

The link you have given uses Internal APIs of Derby, it also requires the debug version of Derby.

As of version 10.10, it still cannot be used as a general SQL Parser as it requires the tables in the SQL to exist - not a good sign that their parser is separate enough for use as a parser! (And in general a worrying sign that their architecture is crap)

Upvotes: 1

Tom Anderson
Tom Anderson

Reputation: 47183

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.

Upvotes: 2

Related Questions