}
if (states.compareAndSet(i, RefState.empty,
RefState.allocated)) {
try {
JDBCPooledConnection connection =
(JDBCPooledConnection) source.getPooledConnection();
connection.addConnectionEventListener(this);
connection.addStatementEventListener(this);
connections[i] = connection;
return connections[i].getConnection();
} catch (SQLException e) {
states.set(i, RefState.empty);