1.SqlMapConfig.xml
作用:配置数据库连接的多种数据,以及引入映射配置文件
2.映射文件例:UserMapper.xml
3.代码中使用
1.创建创建工厂的工人SqlSessionFactoryBuilder
SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
2.加载配置文件
InputStream is = Resources.getResourceAsStream("SqlMapConfig.xml");
3.创建sqlSessionFactory
SqlSesisonFactory factory = builder.build(is);
4.创建SqlSession
SqlSession sqlSession = SqlSessionFactory.openSession();
5.执行sql
User u = sqlSession.selecOne("命名空间.id",参数);