那些验证SQL语法的Java库? [英] Any Java libraries out there that validate SQL syntax?

查看:780
本文介绍了那些验证SQL语法的Java库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定这是否存在,所以我想我会挖掘别人的智慧..

I'm not sure if this even exists or not, so I figured I would tap the wisdom of others..

我想知道是否有任何Java那里的库可以用来验证SQL查询的语法。我知道有许多偏离常见的SQL规范,所以它可能只会对像SQL:2006这样的东西起作用,但这肯定就足够了。

I was wondering if there are any Java libraries out there that can be used to validate a SQL query's syntax. I know that there are many deviations from common SQL spec, so it would probably only work against something like SQL:2006, but that would certainly suffice.

我的目标是将其用于单元测试,而无需尝试对数据库执行。我知道它的用途有限,但它仍然有用。

My goal is to use this for unit-testing purposes without needing to attempt the execution against the DB. I know it's of limited use, but it would still be useful.

谢谢!

推荐答案

我不认为有这样的库。 SQL语法有太多的衍生物。

I don't think there are such libraries. The SQL syntax has too many derivatives.

一种可能的解决方案是使用开源纯Java DBMS的一部分,如 SmallSQL 。在这个项目中,您可以创建 SQLParser 。可以非常轻松地删除对连接所需的引用。

A possible solution would be to use parts of an open source pure Java DBMS like SmallSQL. In this project you can create an instance of the SQLParser. The needed references to the connection can be removed very easily.

这篇关于那些验证SQL语法的Java库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆