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 SELECTsat com.mysql.
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/27 23:24:08
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 SELECTsat com.mysql.
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;
}
}
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 SELECTsat com.mysql.
int count = this.pstmt.executeUpdate();
改为
int count = this.pstmt.executequery();
你执行的是select语句,调用的确实update方法.查询语句要是用查询的方法.