正在加载图片...
简单的连接池( Connectionpoo) public synchronized Connection getConnection ( thr SQLException if(connections. size== 0) return DriverManager getConnection(url, user, passwd)i lse i int lastIndex connections size( return connections. remove(lastindex)i public synchronized void closeConnection(Connection conn) throws SQLException f(connections. size(== max)[ Ise connections. add(conn)简单的连接池(Connectionpool) public synchronized Connection getConnection() throws SQLException { if(connections.size() == 0) { return DriverManager.getConnection(url, user, passwd); } else { int lastIndex = connections.size() - 1; return connections.remove(lastIndex); } } public synchronized void closeConnection(Connection conn) throws SQLException { if(connections.size() == max) { conn.close(); } else { connections.add(conn); } }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有