java : use of executeQuery(string) method not supported error?

前端 未结 2 1092
梦毁少年i
梦毁少年i 2021-01-18 10:15

I\'m doing a simple preparedstatement query execution and its throwing me this error: java.sql.SQLException: Use of the executeQuery(string) method is not supported on this

2条回答
  •  忘掉有多难
    2021-01-18 10:44

    A couple of things are worth checking:

    1. Use a different alias. Using COUNT as an alias would be asking for trouble.
    2. The query object need not be passed twice, once during preparation of the statement and later during execution. Using it in con.prepareStatement(query); i.e. statement preparation, is enough.

    ADDENDUM

    It's doubtful that jTDS supports usage of the String arg method for PreparedStatement. The rationale is that PreparedStatement.executeQuery() appears to be implemented, whereas Statement.executeQuery(String) appears to have been overriden in PreparedStatement.executeQuery() to throw the stated exception.

提交回复
热议问题