When switching between 2 connections, report existing connection parameter to the new used
connection.

@param from used connection
@param to   will-be-current connection
@throws SQLException if catalog cannot be set
968070
public void syncConnection(Protocol from, Protocol to) throws SQLException {

    if (from != null) {

      proxy.lock.lock();
      try {
        to.resetStateAfterFailover(from.getMaxRows(), from.getTransactionIsolationLevel(),
            from.getDatabase(), from.getAutocommit());
      } finally {
        proxy.lock.unlock();
      }

    }
  }
994726
public void prepareToConnect(Request request) {
    if (this.request != null) {
      if (sameConnection(this.request.url(), request.url()) && exchangeFinder.hasRouteToTry()) {
        return; // Already ready.
      }
      if (exchange != null) throw new IllegalStateException();

      if (exchangeFinder != null) {
        maybeReleaseConnection(null, true);
        exchangeFinder = null;
      }
    }

    this.request = request;
    this.exchangeFinder = new ExchangeFinder(this, connectionPool, createAddress(request.url()),
        call, eventListener);
  }
1124581
private void fireConnectionError(SQLException e) {
    Code code = Code.UNKNOWN;
    if (e instanceof CloudSpannerSQLException) {
      code = ((CloudSpannerSQLException) e).getCode();
    }
    if (!isFatalState(code)) {
      return;
    }
    fireConnectionFatalError(e);
  }
1246546
public void switchDataSource(BoneCPConfig newConfig) throws SQLException {
		logger.info("Switch to new datasource requested. New Config: "+newConfig);
		DataSource oldDS = getTargetDataSource();
 
		if (!(oldDS instanceof BoneCPDataSource)){
			throw new SQLException("Unknown datasource type! Was expecting BoneCPDataSource but received "+oldDS.getClass()+". Not switching datasource!");
		}
		
		BoneCPDataSource newDS = new BoneCPDataSource(newConfig);
		newDS.getConnection().close(); // initialize a connection (+ throw it away) to force the datasource to initialize the pool
		
		// force application to start using the new one 
		setTargetDataSource(newDS);
		
		logger.info("Shutting down old datasource slowly. Old Config: "+oldDS);
		// tell the old datasource to terminate. This terminates the pool lazily so existing checked out connections can still be used.
		((BoneCPDataSource)oldDS).close();
	}
1237229
@Override
	public Object toJdbc(final Optional<?> original, final Connection connection,
			final BindParameterMapperManager parameterMapperManager) {
		return original.isPresent() ? parameterMapperManager.toJdbc(original.get(), connection) : null;
	}
447137
public void addCallbackToConnectionIndex(
    ConnectionImpl connection,
    String topicExpression,
    boolean isWildcarded,
    ConsumerSetChangeCallback callback)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        SibTr.entry(
          tc,
          "addCallbackToConnectionIndex",
          new Object[] {connection, topicExpression, new Boolean(isWildcarded), callback });

    // Map of callbacks-to-expressions for a connection
    Map connMap = null;
    if(_callbackIndex.containsKey(connection))
    {
      // Already have registered callbacks for this connection
      connMap = (HashMap)_callbackIndex.get(connection);
    }
    else
    {
      // No registered callbacks for this connection
      connMap = new HashMap();
      _callbackIndex.put(connection,connMap);
    }

    // Add the new callback to the index, so we can find it when we deregister
    TopicRecord tRecord = new TopicRecord(topicExpression, isWildcarded);
    connMap.put(callback, tRecord);

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "addCallbackToConnectionIndex");

  }
319547
protected void closeConnection() throws SQLException {
        if (connection != null && !connection.isClosed()) {
            connection.close();
            connection = null;
        }

    }
883967
public boolean updateDefaultKeys(String from, String to) {
        if (null == from) {
            return false;
        }
        if (null == to) {
            return false;
        }
        if (StringUtils.equals(from, to)) {
            return false;
        }
        String value = this.defaultValues.remove(from);
        if (null == value) {
            return false;
        }
        this.defaultValues.put(to, value);
        return true;
    }
1154454
public void fireConnectionErrorOccured(SQLException ex) {
    ConnectionEvent event = new ConnectionEvent(this, ex);
    for (ConnectionEventListener listener : connectionEventListeners) {
      listener.connectionErrorOccurred(event);
    }
  }
322083
public Connection getConnection() throws SQLException {
		Connection conn = threadLocal.get();
		if (conn != null)
			return conn;
		return showSql ? new SqlReporter(dataSource.getConnection()).getConnection() : dataSource.getConnection();
	}
307064
private void addConnection() throws SQLException {

    //create new connection
    Protocol protocol = Utils.retrieveProxy(urlParser, globalInfo);
    MariaDbConnection connection = new MariaDbConnection(protocol);
    MariaDbPooledConnection pooledConnection = createPoolConnection(connection);

    if (options.staticGlobal) {
      //on first connection load initial state
      if (globalInfo == null) {
        initializePoolGlobalState(connection);
      }
      //set default transaction isolation level to permit resetting to initial state
      connection.setDefaultTransactionIsolation(globalInfo.getDefaultTransactionIsolation());
    } else {
      //set default transaction isolation level to permit resetting to initial state
      connection.setDefaultTransactionIsolation(connection.getTransactionIsolation());
    }

    if (poolState.get() == POOL_STATE_OK
        && totalConnection.incrementAndGet() <= options.maxPoolSize) {
      idleConnections.addFirst(pooledConnection);

      if (logger.isDebugEnabled()) {
        logger.debug("pool {} new physical connection created (total:{}, active:{}, pending:{})",
            poolTag, totalConnection.get(), getActiveConnections(), pendingRequestNumber.get());
      }
      return;
    }

    silentCloseConnection(pooledConnection);
  }
798972
@Override
    public boolean doConnectionCleanup(Connection conn) throws SQLException {
        final boolean trace = TraceComponent.isAnyTracingEnabled();
        if (trace && tc.isEntryEnabled())
            Tr.entry(tc, "doConnectionCleanup");
        boolean result = false;
        try {
            Class<?> c = OracleConnection.get();
            if (c == null)
                OracleConnection.set(c = WSManagedConnectionFactoryImpl.priv.loadClass(mcf.jdbcDriverLoader, oracle_jdbc_OracleConnection));

            if (c.isInstance(conn)) {
                try {
                    Method m = isProxySession.get();
                    if (m == null)
                        isProxySession.set(m = c.getMethod("isProxySession"));

                    if ((Boolean) m.invoke(conn)) {
                        m = close.get();
                        if (m == null)
                            close.set(m = c.getMethod("close", int.class));
                        m.invoke(conn, 1); // value of OracleConnection.PROXY_SESSION
                        result = true;
                    }
                } catch (NoSuchMethodException nsme) {
                    // This is expected when older version of the Oracle JDBC Driver
                    // like classes12.zip are being used
                }
            }
        } catch (RuntimeException x) {
            throw x;
        } catch (Exception x) {
            throw AdapterUtil.toSQLException(x);
        }

        if (trace && tc.isEntryEnabled())
            Tr.exit(tc, "doConnectionCleanup", result);
        return result;
    }
397190
public function resetReviews($from = null, $to = null)
    {
        $conn = $this->getConnection();
        if ($from && $to) {
            $where = [
                'created_at >= ?' => $from . ' 00:00:00',
                'created_at <= ?' => $to . ' 23:59:59',
                'review_imported is ?' => new \Zend_Db_Expr('not null')
            ];
        } else {
            $where = $conn->quoteInto(
                'review_imported is ?',
                new \Zend_Db_Expr('not null')
            );
        }
        $num = $conn->update(
            $this->getTable(Schema::EMAIL_REVIEW_TABLE),
            ['review_imported' => new \Zend_Db_Expr('null')],
            $where
        );

        return $num;
    }
272690
public void switchReadOnlyConnection(Boolean mustBeReadOnly) throws SQLException {
    if (urlParser.getOptions().assureReadOnly && currentReadOnlyAsked != mustBeReadOnly) {
      proxy.lock.lock();
      try {
        // verify not updated now that hold lock, double check safe due to volatile
        if (currentReadOnlyAsked != mustBeReadOnly) {
          currentReadOnlyAsked = mustBeReadOnly;
          setSessionReadOnly(mustBeReadOnly, currentProtocol);
        }
      } finally {
        proxy.lock.unlock();
      }
    }
  }
678897
protected static void sendInitSQL(Connection connection, String initSQL) throws SQLException{
		// fetch any configured setup sql.
		if (initSQL != null){
			Statement stmt = null;
			try{
				stmt = connection.createStatement();
				stmt.execute(initSQL);
				if (testSupport){ // only to aid code coverage, normally set to false
					stmt = null;
				}
			} finally{
				if (stmt != null){
					stmt.close();
				}
			}
		}
	}
1318035
@Override
  public void initializeConnection() throws SQLException {
    super.initializeConnection();
    try {
      reconnectFailedConnection(new SearchFilter(true));
    } catch (SQLException e) {
      //initializeConnection failed
      checkInitialConnection(e);
    }
  }
1308734
protected void postInit(Connection connection) throws SQLException
   {
      String select =
         "select * from " + DBInitializerHelper.getItemTableName(containerConfig) + " where ID='"
            + Constants.ROOT_PARENT_UUID + "' and PARENT_ID='" + Constants.ROOT_PARENT_UUID + "'";

      if (!connection.createStatement().executeQuery(select).next())
      {
         String insert = DBInitializerHelper.getRootNodeInitializeScript(containerConfig);
         connection.createStatement().executeUpdate(insert);
      }
   }