public static int close() { int count = 0; Iterator iterator = m_notUsedConnection.iterator(); while (iterator.hasNext()) { try { ((ConnectionWrapper) iterator.next()).close(); count++; } catch (Exception e) { } } m_notUsedConnection.clear(); iterator = m_usedUsedConnection.iterator(); while (iterator.hasNext()) { try { ConnectionWrapper wrapper = (ConnectionWrapper) iterator.next(); wrapper.close(); if (DEBUG) { wrapper.debugInfo.printStackTrace(); } count++; } catch (Exception e) { } } m_usedUsedConnection.clear(); return count; }
public static synchronized Connection getConnection() { clearClosedConnection(); while (m_notUsedConnection.size() > 0) { try { ConnectionWrapper wrapper = (ConnectionWrapper) m_notUsedConnection.removeFirst(); if (wrapper.connection.isClosed()) { continue; } m_usedUsedConnection.add(wrapper); if (DEBUG) { wrapper.debugInfo = new Throwable("Connection initial statement"); } return wrapper.connection; } catch (Exception e) { } } int newCount = getIncreasingConnectionCount(); LinkedList list = new LinkedList(); ConnectionWrapper wrapper = null; for (int i = 0; i < newCount; i++) { wrapper = getNewConnection(); if (wrapper != null) { list.add(wrapper); } } if (list.size() == 0) { return null; } wrapper = (ConnectionWrapper) list.removeFirst(); m_usedUsedConnection.add(wrapper); m_notUsedConnection.addAll(list); list.clear(); return wrapper.connection; }