有几件事值得检查:
- 使用其他别名。使用COUNT作为别名会带来麻烦。
- 查询对象不需要两次传递,一次是在语句准备期间传递,另一次是在执行期间传递。在
con.prepareStatement(query);
声明准备中使用它就足够了。
附录
怀疑jTDS是否支持将String
arg方法用于PreparedStatement。这样做的理由是,PreparedStatement.executeQuery()似乎已实现,而Statement.executeQuery(String)似乎已在PreparedStatement.executeQuery()中被重写以引发所述异常。



