读书人

数据库连接开启与封锁

发布时间: 2012-09-18 16:21:42 作者: rapoo

数据库连接开启与关闭
private static final ThreadLocal threadSession = new ThreadLocal(); public static Session getSession() throws InfrastructureException { Session s = (Session) threadSession.get(); try { if (s == null) { s = getSessionFactory().openSession(); threadSession.set(s); } } catch (HibernateException ex) { throw new InfrastructureException(ex); } return s; }

?

读书人网 >其他数据库

热点推荐