简体   繁体   English

如何使用javadb作为sql解析器

[英]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. 大约一个月前,我构建了一个使用zSQL作为SQL解析器来解析sql的应用程序。 However, just few days ago, a heave duty user sent in a multi row insert statement which zSQL doesnt support. 然而,就在几天前,一个升级责任用户发送了一个zSQL不支持的多行插入语句。 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". 然后我找到了这个链接: http ://weblogs.java.net/blog/2008/11/23/stand-alone-sql-parser-java,它说“通过简单的修复,Rick Hillegas确保开发人员可以拥有访问Apache / Derby附带的强大的SQL解析器“。 However, i cant find any relevant documentation to achieve this. 但是,我无法找到任何相关文档来实现这一目标。

Any idea? 任何想法?

Did you try clicking on the link 'a simple fix' in that post on java.net? 您是否尝试过点击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. 如果您阅读ASTParser.java的代码 ,您可以看到编写以使用解析器所需的代码。

The link you have given uses Internal APIs of Derby, it also requires the debug version of Derby. 您提供的链接使用Derby的内部API,它还需要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! 从版本10.10开始,它仍然不能用作一般的SQL Parser,因为它需要SQL中的表存在 - 这并不是一个好的迹象,表明它们的解析器足够独立,可以用作解析器! (And in general a worrying sign that their architecture is crap) (总的来说,一个令人担忧的迹象表明他们的架构是垃圾)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM