关闭连接仍在连接池中 - 为什么?
servlet-
public class Index extends HttpServlet {
TimeZoneService timeZoneService;
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException {
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
timeZoneService = (TimeZoneService) ctx.getBean("timeZoneService");
timeZoneService.loadAllTimeZones();
System.out.println("Done");
}
}
public interface TimeZoneService {
void loadAllTimeZones();
}
public class TimeZoneServiceImpl implements TimeZoneService {
private TimeZoneDao tzDao;
private Map<Long, String> tzOid2JavaName = new HashMap<Long, String>();
public void loadAllTimeZones() {
List<TimeZone> timeZones = tzDao.findAllTimeZones();
for (TimeZone tz : timeZones) {
tzOid2JavaName.put(tz.getOid(), tz.getJavaName());
}
}
public void setTzDao(TimeZoneDao tzDao) { …
Run Code Online (Sandbox Code Playgroud)