在springmvc中,获取Connection接口

ServletContext context = request.getSession().getServletContext();
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(context);
DataSource dbSource = (DataSource) wac.getBean("dataSource"); //配置文件里的beanid
Connection con = null;
try {
con = dbSource.getConnection();
} catch (SQLException e) {
e.printStackTrace();
}
原文地址:https://www.cnblogs.com/liduanwen/p/4736457.html