Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any Java libraries out there that validate SQL syntax? [closed]

Tags:

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

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.

Thanks!

like image 329
awied Avatar asked Sep 26 '08 19:09

awied


People also ask

How do you validate a SQL query?

To validate the syntax of the statements, right-click in the editor, and then select a validation option. To validate the syntax of the statements for the connection that is selected in the Configuration tab, select the Validate statement syntax for current configuration option.

How do you check SQL query is correct or not?

First, Drag and drop your SQL file or copy / paste your request directly into the editor above. Finally, you must click on "Check SQL syntax" button to display if there is an syntax error in your code.

Is Java compatible with SQL?

As of Microsoft JDBC Driver 11.2 for SQL Server, Java Development Kit (JDK) 18.0 and Java Runtime Environment (JRE) 18.0 are supported. As of Microsoft JDBC Driver 10.2 for SQL Server, Java Development Kit (JDK) 17.0 and Java Runtime Environment (JRE) 17.0 are supported.

Where are SQL queries stored Java?

The best practice should be to store the sql statements in a properties file. And get the statements in the DAO object through an interface to properties files, say java. util. Properties.


1 Answers

Perhaps you can use Antlr, it has a number of SQL grammars and a Java library, as well as plugins for various Java IDEs.

Or as advised, use the parser of open source SQL utilities like SQuirreL SQL Client.

like image 84
PhiLho Avatar answered Sep 19 '22 20:09

PhiLho