如何使用 JavaDB 作为 SQL 解析器
大约一个月前,我构建了一个应用程序,使用 zSQL 作为 SQL 解析器来解析 SQL。然而,就在几天前,一位重度用户发送了 zSQL 不支持的多行插入语句。这是示例:
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
然后我找到了这个链接: http://weblogs.java.net/blog/2008/11/23/stand-alone-sql-parser-java,它说“通过一个简单的修复,Rick Hillegas 已确保开发人员可以访问到 Apache/Derby 附带的强大 SQL 解析器”。但是,我找不到任何相关文档来实现此目的。
有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试单击 java.net 上该帖子中的“简单修复”链接?第一条评论显示了如何运行该工具。如果您阅读ASTParser.java的代码,您可以看到使用解析器需要编写的代码。
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.
您提供的链接使用 Derby 的内部 API,它还需要 Derby 的调试版本。
从版本 10.10 开始,它仍然不能用作通用 SQL 解析器,因为它需要 SQL 中的表存在 - 这不是一个好兆头,表明它们的解析器足够独立以用作解析器! (总的来说,这是一个令人担忧的迹象,表明他们的架构很糟糕)
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)