需要先配置这个xml基于mybtis的XML配置,完成对mySql数据库的SQL语句配置_你挚爱的强哥❤给你发来1条消息❤-CSDN博客
SqlSession sqlSession = new SqlSessionFactoryBuilder().build(Resources.getResourceAsReader("mybatis-config.xml")).openSession(); UserMapper mapper = sqlSession.getMapper(UserMapper.class); Listu = mapper.selectAll(); for (Users a : u) System.out.println(a.name);System.out.println(mapper.select(55)); mapper.insert(new User("插入的姓名", 66)); mapper.delete(new User(55)); mapper.update(new User(60, "修改后的姓名", 33)); sqlSession.commit();sqlSession.close();
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)