【发布时间】:2010-08-05 21:22:53
【问题描述】:
我正在执行一个简单的preparedstatement 查询执行,它向我抛出了这个错误: java.sql.SQLException:net.sourceforge.jtds.jdbc.JtdsPreparedStatement.notSupported(JtdsPreparedStatement.java:197) 上的此类语句不支持在 net.sourceforge.jtds.jdbc 上使用 executeQuery(string) 方法。 JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:822) 在 testconn.itemcheck(testconn.java:58)
任何想法我做错了什么?提前致谢 这是代码:
private static int itemcheck (String itemid ) {
String query;
int count = 0;
try {
Class.forName("net.sourceforge.jtds.jdbc.Driver");
con = java.sql.DriverManager.getConnection(getConnectionUrl2());
con.setAutoCommit(false);
query = "select count(*) as itemcount from timitem where itemid like ?";
//PreparedStatement pstmt = con.prepareStatement(query);
//pstmt.executeUpdate();
PreparedStatement pstmt = con.prepareStatement(query);
pstmt.setString(1,itemid);
java.sql.ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
count = rs.getInt(1);
System.out.println(count);
} //end while
}catch(Exception e){ e.printStackTrace(); }
return (count);
} //end itemcheck
【问题讨论】:
标签: java sql-server