package dao; import org.apache.ibatis.session.SqlSession; import org.junit.Test; import pojo.User; import utils.MybatisUtils; import java.util.List; public class UserDaoTest { @Test public void test(){ SqlSession sqlSession = MybatisUtils.getSqlSession(); UserDao mapper = sqlSession.getMapper(UserDao.class); List<User> userList = mapper.getUserList(); for (User user : userList) { System.out.println(user); } sqlSession.close(); } @Test public void adduser(){ SqlSession sqlSession = MybatisUtils.getSqlSession(); UserDao mapper = sqlSession.getMapper(UserDao.class); mapper.insertdata(new User(7, "'事实上'", "6")); sqlSession.commit(); sqlSession.close(); } }
在数据库设置单元为字符串时,输入需要带“”
若字符串中要输入字母,还要单独使用‘’