作业帮 > 综合 > 作业

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

来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/04/29 01:38:48
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;
}
}
int count = this.pstmt.executeUpdate();
改为
int count = this.pstmt.executequery();
你执行的是select语句,调用的确实update方法.查询语句要是用查询的方法.
再问: TeacherDaoImpl.java中 DBCPConnection.java中loginaction中报错