import mapper.StudentMapper;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;
import pojo.Student;
import util.mybatisunti;
public class Tesyt {
@Test
public void testupdate(){
SqlSession sqlSession = mybatisunti.openSqlSession();
StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);
Student student = new Student("0013","杨六","15","深圳","96");
int cout = mapper.update(student);
System.out.println(cout);
}
@Test
public void testdelect(){
SqlSession sqlSession = mybatisunti.openSqlSession();
StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);
int cout = mapper.delect("0013");
System.out.println(cout);
}
}
mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="mapper.StudentMapper">
<update id="update" >
update
students
set
name=#{name},age=#{age},nativee=#{nativee},grage=#{grage}
where
sno = #{sno}
update>
<delete id="delect">
delete from students where sno=#{sno}
delete>
mapper>
package mapper;
import pojo.Student;
public interface StudentMapper {
//插入
int inset(Student stu);
//查询
Student select(String sno);
//删除
int delect(String sno);
//更新
int update(Student stu);
}
mybatisunti
这个类的代码截图