获取spring applicationcontext数据连接connection

                 ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
//                 DataSource  dataSource = (DataSource) context.getBean("dataSource");
         //       ApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"applicationContext.xml"});
                DataSource dataSource =(DataSource) context.getBean("dataSource");
                Connection conn = (Connection) dataSource.getConnection();  

 

posted on 2017-09-11 16:51  Honey_Badger  阅读(462)  评论(0编辑  收藏  举报

导航

github