开发者

Does MySQL's JDBC driver have a facility for parsing SQL?

开发者 https://www.devze.com 2023-01-26 13:11 出处:网络
I\'m writing a Java tool to validate SQL statements. For SELECT queries, I can do it with Connection.prepareStatement and PreparedStatemet.getMetaData. No exceptions == good query. Unfourtunately it d

I'm writing a Java tool to validate SQL statements. For SELECT queries, I can do it with Connection.prepareStatement and PreparedStatemet.getMetaData. No exceptions == good query. Unfourtunately it doesn't work with eg. INSERT statements -- errors in query create exception only at executing t开发者_运维知识库he statement.

Is there a way to parse SQL via JDBC without executing the statement? An internal method maybe?

Unfourtunately I was also unable to find source code for Connector/J -- I'd be grateful for links to it.


OK, found an answer myself, need to call a protected method:com.mysql.jdbc.ServerPreparedStatement.getInstance(MySQLConnection conn, String sql, String catalog, int, int)

0

精彩评论

暂无评论...
验证码 换一张
取 消