这是代码package com.oaec.daoImpl;
import java.util.List;
import javax.security.auth.message.callback.PrivateKeyCallback.Request;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import com.oaec.dao.TeacherDao;
import com.oaec.entity.Teacher;
@Repository("teacherDao")
public class TeacherImpl implements TeacherDao {
@Autowired
private JdbcTemplate jdbcTemplate;
//查询
@Override
public List<Teacher> queryAll() {
String sql = "select * from teacher";
List<Teacher> list=jdbcTemplate.query(sql, new BeanPropertyRowMapper<Teacher>(Teacher.class));
return list;
}
//删除
@Override
public int delTeacher(int id) {
String sql = "delete from teacher where id=? ";
int num=jdbcTemplate.update(sql,id);
return num;
}
//添加
@Override
public int add(Teacher teacher) {
String sql = "insert into teacher (name,title,password) values(?,?,?)";
int num = jdbcTemplate.update(sql, teacher);
return num;
}
1 个解决方案
#1
看看你的teacher类中有没有title属性,或者是这个属性没赋值
总之就是少了参数,检查一下三个属性都有值没
总之就是少了参数,检查一下三个属性都有值没
#1
看看你的teacher类中有没有title属性,或者是这个属性没赋值
总之就是少了参数,检查一下三个属性都有值没
总之就是少了参数,检查一下三个属性都有值没