Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check SQL syntax for a JDBC statement without running the actual query?

I have an SQL statement (for an Oracle database) that takes a long time to run if it is valid. If it's not valid, it returns immediately with an error.

I'd like to check that the syntax is valid without running the statement (via JDBC), for example behind a 'check statement' button. Is there a vendor-independent way of doing that? My first thought of simply defining the query as a PreparedStatement does not seem to cause any kind of compilation or error checking.

like image 353
brabster Avatar asked Apr 20 '12 13:04

brabster


1 Answers

possibly issuing an explain plan for the statement would give you useful results.

another thought - but maybe harder is to edit the query to add (and rownum < 1) or something to make it run fast

like image 131
Randy Avatar answered Sep 21 '22 18:09

Randy