Connects to the database.
761248
def connect(user, password)
      logger.debug { "Connecting to application server with login id #{user}..." }
      begin
        @session.start_session(user, password)
      rescue Exception => e
        logger.error("Login of #{user} with password #{password} was unsuccessful - #{e.message}")
        raise e
      end
      logger.info("Connected to application server.")
    end
150770
public static function connectDb() {
        if 
            (!isset(self::$dbLink)) {
            $dbParams = self::getDatabaseParameters();
            self::validateDbParameters($dbParams);
            $dbParamsSan = self::sanitizeDbParameters($dbParams);
            $config = new Configuration();
            self::$dbLink = DriverManager::getConnection($dbParamsSan, $config);
        }
        
        return self::$dbLink;
    }
166581
def connect(self):
        '''
        
        '''
        if self.connected:
            raise RuntimeError(
                '{} is connected already'.format(self.__class__.__name__))
        if self.closed:
            raise RuntimeError(
                '{} is closed already'.format(self.__class__.__name__))
        self.connected = True
        self._connect()
165894
public function connectToDB(){
        //if querybuilder is already connected there is no nedd to connect again
        if($this->queryBuilder->isConnected()) {
            return;
        }
        //check for database parameters
        if(empty($this->DBParameters)) {
            throw new \Exception('missing database parameters');
        }
        $this->queryBuilder->connect(
            $this->DBParameters['driver'],
            $this->DBParameters['host'],
            $this->DBParameters['database'],
            $this->DBParameters['username'],
            $this->DBParameters['password'],
            $this->DBParameters['charset'],
            $this->DBParameters['collation'],
            $this->DBParameters['options']
        );
    }
1121273
def connection(connection, without_connection_test):
    """"""
    database.set_connection(connection=connection)

    if not without_connection_test:
        test_connection(connection)
43534
public function connect()
	{
		if ($this->_connection)
		{
			return;
		}

		// Extract the connection parameters, adding required variabels
		extract($this->_config['connection'] + array(
			'dsn'        => '',
			'username'   => null,
			'password'   => null,
			'persistent' => false,
			'compress'   => false,
		));

		// determine db type
		$_dsn_find_collon = strpos($dsn, ':');
		$this->_db_type = $_dsn_find_collon ? substr($dsn, 0, $_dsn_find_collon) : null;

		// Force PDO to use exceptions for all errors
		$attrs = array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION);

		if ( ! empty($persistent))
		{
			// Make the connection persistent
			$attrs[\PDO::ATTR_PERSISTENT] = true;
		}

		if (in_array(strtolower($this->_db_type), array('mysql', 'mysqli')) and $compress)
		{
			// Use client compression with mysql or mysqli (doesn't work with mysqlnd)
			$attrs[\PDO::MYSQL_ATTR_COMPRESS] = true;
		}

		// add the charset to the DSN if needed
		if ( ! empty($this->_config['charset']) and strpos($dsn, ';charset=') === false and strtolower($this->_db_type) != 'sqlite')
		{
			$dsn .= ';charset='.$this->_config['charset'];
		}

		try
		{
			// Create a new PDO connection
			$this->_connection = new \PDO($dsn, $username, $password, $attrs);
		}
		catch (\PDOException $e)
		{
			// and convert the exception in a database exception
			if ( ! is_numeric($error_code = $e->getCode()))
			{
				if ($this->_connection)
				{
					$error_code = $this->_connection->errorinfo();
					$error_code = $error_code[1];
				}
				else
				{
					$error_code = 0;
				}
			}
			throw new \Database_Exception(str_replace($password, str_repeat('*', 10), $e->getMessage()), $error_code, $e);
		}

		if ( ! empty($this->_config['charset']))
		{
			// Set the character set
			$this->set_charset($this->_config['charset']);
		}
	}
760828
private function connect()
    {
        $this->conn = parent::getConn();
        $this->update = $this->conn->prepare($this->update);
    }
1047342
def _connect(self, config):
        """"""
        if 'connection_timeout' not in self._config:
            self._config['connection_timeout'] = 480
        try:
            self._cnx = connect(**config)
            self._cursor = self._cnx.cursor()
            self._printer('\tMySQL DB connection established with db', config['database'])
        except Error as err:
            if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
                print("Something is wrong with your user name or password")
            elif err.errno == errorcode.ER_BAD_DB_ERROR:
                print("Database does not exist")
            raise err
462206
private function loadDatabaseConnection()
    {
        /**
         * Setup for 'illuminate/database'
         */
        $capsule = new Manager;
        $capsule->addConnection($this->settings['db']);
        $capsule->setAsGlobal();
        $capsule->bootEloquent();
        $capsule::connection();
    }
1029994
public function connect()
    {
        // Lookup Adapter-Specific Connection Properties
        $strServer = $this->Server;
        $strName = $this->Database;
        $strUsername = $this->Username;
        $strPassword = $this->Password;
        $strPort = $this->Port;

        // Connect to the Database Server
        $this->objPgSql = pg_connect(sprintf('host=%s dbname=%s user=%s password=%s port=%s', $strServer, $strName,
            $strUsername, $strPassword, $strPort));

        if (!$this->objPgSql) {
            throw new \Exception("Unable to connect to Database", -1, null);
        }

        // Update Connected Flag
        $this->blnConnectedFlag = true;
    }
416505
def connect(self):
        

        attempt = 0
        for i in self.max_tries_counter:
            attempt += 1
            try:
                self._conn = self._connect()
            except ConnectionError as exc:
                logger.warning('Attempt %s/%s. Connection to %s:%s failed after %sms.',
                               attempt, self.max_tries if self.max_tries != 0 else '∞',
                               self.host, self.port, self.connection_timeout)
                if attempt == self.max_tries:
                    logger.critical('Cannot connect to the Database. Giving up.')
                    raise ConnectionError() from exc
            else:
                break
908217
public function connect(): DatabaseConnection
    {
        if (null !== $this->pdo) {
            return $this;
        }

        try {
            $pdoCreator = $this->getPdoCreator();
            $this->pdo  = $pdoCreator($this->configuration);
            $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            $this->pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
            if ($this->configuration->hasInitialQuery()) {
                $this->pdo->query($this->configuration->getInitialQuery());
            }
        } catch (PDOException $pdoe) {
            throw new DatabaseException($pdoe->getMessage(), $pdoe);
        }

        return $this;
    }
487520
private function connect()
    {
        $dsn = "{$this->credentials->getDriver()}:host={$this->credentials->getHost()}";

        try {
            $pdo = new \PDO($dsn, $this->credentials->getUsername(), $this->credentials->getPassword());
        } catch (\PDOException $e) {
            throw new \RuntimeException('Failed to connect to database.', 0, $e);
        }

        $this->pdo = $pdo;

        if (null !== $this->credentials->getCharset()) {
            $this->setCharset($this->credentials->getCharset());
        }

        if (null !== $this->credentials->getDatabase()) {
            $this->selectDatabase($this->credentials->getDatabase());
        }
    }
487949
@Override
  public void connect() {
    if (!canRun.compareAndSet(true, false) || clientBase.isDone()) {
      throw new IllegalStateException("There is already a connection thread running for " + this.clientBase);
    }
    executorService.execute(clientBase);
    logger.info("New connection executed: {}", this.clientBase);
  }
941583
private Connection connect()
            throws SQLException {

        if (DefaultContentLoader.localDataSource == null) {
            LOG.error("Data Source is null");
            return null;
        }

        final Connection conn = DataSourceUtils.getConnection(DefaultContentLoader.localDataSource);
        if (conn == null) {
            LOG.error("Connection is null");
        }

        return conn;
    }
698573
public function connect()
    {
        $dsn = "sqlite:{$this->_file}";
        try {
            $class = $this->_handlerClass;
            $this->_handler = new $class($dsn);
            $this->_handler->setAttribute(
                PDO::ATTR_ERRMODE,
                PDO::ERRMODE_EXCEPTION
            );
            $this->_connected = true;
        } catch (\Exception $exp) {
            throw new ServiceException(
                "An error occurred when trying to connect to database " .
                "service. Error: {$exp->getMessage()}"
            );
        }
        return $this;
    }
725132
public function connectToDb()
    {
        $this->con = new PDO("mysql:host=$this->host", $this->username, $this->password);
        $this->con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $this->con->query("CREATE DATABASE IF NOT EXISTS " . $this->dbName);
        $this->con->query("USE " . $this->dbName);
    }