异常详情:
java.sql.SQLException: No value specified for parameter 1 at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:396) at com.zy.jdbc.dao.impl.StudentDaoImpl.update(StudentDaoImpl.java:69)
源码:
preparedStatement.setString(1,student.getName()); preparedStatement = connection.prepareStatement(sql); preparedStatement.setInt(2,student.getAge()); preparedStatement.setDate(3,new Date(student.getBir().getTime())); preparedStatement.setString(4,student.getId()); preparedStatement.execute();
解决:应该先执行connection.prepareStatement(sql),再给参数赋值



