code: public final Connection getConnection() throws SQLException {
  
        final Timer.Context ctx = acquisitions.time();
  
        try {
  
           Connection conn;
           for(int i = 0; i < activeSegments; i++) {
              conn = segments[i].open();
              if(conn != null) {
                 return conn;
              }
           }
  
           //All connections for active segments were in-use.
           //Send signal to attempt to activate a new segment then
           //try the active segments in-order (again) with the acquire time-out.
  
           signalActivateSegment();
  
           try {
  
              for(int i = 0; i < activeSegments; i++) {
                 ConnectionPoolSegment segment = segments[i];
                 conn = segment.open(segment.acquireTimeoutMillis, TimeUnit.MILLISECONDS);
                 if(conn != null) {
                    return conn;
                 }
              }
  
           } catch(InterruptedException ie) {
              Thread.currentThread().interrupt();
              throw new SQLException("Connection pool, '" + name + "' interrupted during acquire", JDBConnection.SQLSTATE_CONNECTION_EXCEPTION);
           }
  
           //Try all pools again with maximum acquire timeout.
  
           long maxTimeoutMillis = saturatedAcquireTimeoutMillis / activeSegments;
  
           try {
  
              for(int i = 0; i < activeSegments; i++) {
                 ConnectionPoolSegment segment = segments[i];
                 conn = segment.open(maxTimeoutMillis, TimeUnit.MILLISECONDS);
                 if(conn != null) {
                    return conn;
                 }
              }
  
           } catch(InterruptedException ie) {
              Thread.currentThread().interrupt();
              throw new SQLException("Connection pool, '" + name + "' interrupted during acquire", JDBConnection.SQLSTATE_CONNECTION_EXCEPTION);
           }
  
           //Done trying
  
           failedAcquisitions.mark();
  
           throw new SQLException(SATURATED_MESSAGE, JDBConnection.SQLSTATE_CONNECTION_FAILURE);
  
        } finally {
           ctx.stop();
        }
     }
docs: Gets a connection.
  @return The connection
  @throws SQLException If no connection is available.