@SuppressWarnings({"unchecked", "static-access"}) public static synchronized void initConnectionPool() throws SQLException, ClassNotFoundException { ConnectionPool.getConnectionPool().destoryConnectionPool(); @SuppressWarnings("rawtypes") Vector temp = ConnectionPool.getConnectionPool().getConnectionPoolBuffer(); ConnectionFactory connectionFactory = ConnectionFactory.getDefaultFactory(); for (int i = 0; i < MAX_CONNECTION; i++) { Connection connection = connectionFactory.createConnection("mysql"); temp.addElement(new ConnectionInfo(connection, System.currentTimeMillis())); System.out.println("New Connection Created.." + connection); } }
public static synchronized void destoryConnectionPool() { @SuppressWarnings("rawtypes") Vector temp = ConnectionPool.getConnectionPool().getConnectionPoolBuffer(); int t = temp.size(); System.out.println("버퍼의 크기는" + t); for (int i = 0; i < t; i++) { ConnectionInfo connectionInfo = (ConnectionInfo) temp.remove(0); if (connectionInfo != null) { try { connectionInfo.connection.close(); System.out.println("Connection Closed" + connectionInfo.connection); } catch (SQLException e) { e.printStackTrace(); } } } }