码迷,mamicode.com
首页 > 其他好文 > 详细

MyBatis 【单独连接】

时间:2016-02-14 15:26:28      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:

        Configuration conf = new Configuration();
        
        conf.setEnvironment(
                new Environment.Builder("only")
                .transactionFactory(new JdbcTransactionFactory())
                .dataSource(new PooledDataSource(
                        "com.mysql.jdbc.Driver",
                        "jdbc:mysql://127.0.0.1:3306/xxx_rule_engine",
                        "root",
                        "123456"
                        )).build());
        
        conf.addMapper(PrizeMapper.class);
        
        SqlSessionFactory ssf = new SqlSessionFactoryBuilder().build(conf);
        SqlSession openSession = ssf.openSession();
        PrizeMapper mapper = openSession.getMapper(PrizeMapper.class);
        
        List<PrizeModel> list = mapper.list(new PrizeModel());
        
        System.out.println(list);

 

MyBatis 【单独连接】

标签:

原文地址:http://www.cnblogs.com/luffya/p/5189028.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!