Java 的 SQL 解析器库 [英] SQL parser library for Java
本文介绍了Java 的 SQL 解析器库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有用于解析 SQL 语句的开源 Java 库?
如果可能,它应该是可定制的或足够灵活,以便还能够解析(或至少忽略)特定于供应商的语法(例如 Oracle 表空间定义或 MySQL 的 LIMIT 子句).
如果没有,严格遵守 SQL 标准也没有问题.
更新:我需要它来做两件事:
- 为非 SQL 数据库提供 SQL 接口(映射到内部 API 调用)
- 在进入实际数据库(例如 Oracle)之前重写 SQL
解决方案
ANTLR3 有ANSI SQL 语法可用.您可以使用它来创建自己的解析器.
ANTLR4 有一个 SQL 语法.>
Is there an open-source Java library for parsing SQL statements?
If possible, it should be customizable or flexible enough to also be able to parse (or at least ignore) vendor-specific syntax (such as Oracle tablespace definitions or MySQL's LIMIT clause).
If not, strict adherence to the SQL standard is also fine.
Update: I need this for two things:
- providing an SQL interface to a non-SQL database (mapping to internal API calls)
- rewriting SQL before it goes to the actual database (e.g. Oracle)
解决方案
ANTLR3 has an ANSI SQL grammar available. You can use that to create your own parser.
ANTLR4 has a SQL grammar.
这篇关于Java 的 SQL 解析器库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文