public int Insert(Course cou) throws SQLException{
Connection con = jdbc.con();//连接数据库
//sql语句的预编译防止sql注入 ,?代表占位符
//表名和属性要与数据库表明和属性一至
String sql = "insert into course (id,name,type,grade,teacher,introduction) values(?,?,?,?,?,?)";
//创建PreparedStatement对象用来执行sql语句
PreparedStatement per = con.prepareStatement(sql);
//添加和得到各个属性的值
per.setString(1, cou.getId());
per.setString(2,cou.getName());
per.setString(3,cou.getType());
per.setDouble(4, cou.getGrade());
per.setInt(5,(int)cou.getGrade()*18);
per.setString(6, cou.getTeacher());
per.setString(7, cou.getIntroduction());
//执行sql语句,executeUpdate()获取影响的行数并返回
int rows = per.executeUpdate();
return rows;
}
数据库中一共有七个属性,第五个属性time的值是第四个grade乘以18,但是我传入的参数不包括time,我想自动更新time。请问这个代码怎么改呀,一直报错