java 1.4 Sql server 2000
i am taking input of sql query (for validation of field value against values retrieved by executing sql query) from admin user which will be stored in database and later i will executing sql query corresponding to field.Before inserting sql query in database i want to validate its syntax in java code.
Fields Sql Query
stateCode select statecode from states
district code select district code from districts
Create a PreparedStatement with the query string; if this works, the query string is ok (but nothing is executed yet)
dont think there is any (easy) way to validate sql
Sql syntax is complex and allows for alot of different ways to enter a statement.
Think you best shot would be to just execute the sql statent and if you have a SQl exception see if its a bad syntax thats causing it.
you can prepend some sql to avoid from actually executing the query
in sybase it would be SET NOEXEC ON
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With