SQL >select count(*) from Teacher where teacherCode=? and te

SQL >select count(*) from Teacher where teacherCode=? and teacherPassword=? java.sql.SQLException:
SQL >select count(*) from Teacher where teacherCode=? and teacherPassword=?
java.sql.SQLException: Can not issue executeUpdate() for SELECTs
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
public int execOther(final String strSQL, final Object[] params){
this.fetchFreeConnection();
try {
this.pstmt = this.conn.prepareStatement(strSQL);
System.out.println(new Date()+"nSQL >"+strSQL);
for (int i = 0; i < params.length; i++) {
this.pstmt.setObject(i+1, params[i]);
}
int count = this.pstmt.executeUpdate();
return count;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return -1;
}
}
zvzlove 1年前 已收到1个回答 举报

wwwdww 春芽

共回答了25个问题采纳率:92% 举报

int count = this.pstmt.executeUpdate();
改为
int count = this.pstmt.executequery();
你执行的是select语句,调用的确实update方法.查询语句要是用查询的方法.

1年前 追问

6

zvzlove 举报

TeacherDaoImpl.java中

DBCPConnection.java中

loginaction中

报错

可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 17 q. 2.725 s. - webmaster@yulucn.com