Connects to dabatase, checks the version and creates the
    design document used by feat (if it doesn't exist).

    @returns: IDatabaseConnection bound to _replicator database
559324
def configure_replicator_database(host, port, username=None, password=None):
    
    database = driver.Database(host, port, '_replicator', username, password)
    connection = database.get_connection()
    version = yield database.get_version()
    if version < (1, 1, 0):
        database.disconnect()
        raise ValueError("Found couchdb version %r. "
                         "_replicator database has been introduced in 1.1.0." %
                         (version, ))
    design_docs = view.DesignDocument.generate_from_views([Replications])
    for doc in design_docs:
        try:
            doc2 = yield connection.get_document(doc.doc_id)
            if doc.views != doc2.views or doc.filters != doc2.filters:
                doc.rev = doc2.rev
                yield connection.save_document(doc)

        except NotFoundError:
            yield connection.save_document(doc)
    defer.returnValue(connection)
1269658
public function setConnection()
	{
		$connection = Config::get('core::database.default');

		if ($connection !== 'default')
		{
			$wardrobeConfig = Config::get('core::database.connections.'.$connection);
		}
		else
		{
			$connection = Config::get('database.default');
			$wardrobeConfig = Config::get('database.connections.'.$connection);
		}

		Config::set('database.connections.wardrobe', $wardrobeConfig);
	}
44346
private void connect_to_dbase(final Connection connection) throws DevFailed {
		if (connection.device == null) {
	    	try {
                // Prepare the connection string
                final String db_corbaloc = "corbaloc:iiop:" + connection.url.host + ":"
                    + connection.url.strPort + "/database";
                // And connect to database.
                createDevice(connection, db_corbaloc);
                connection.classname = "Database";
 	    	} catch (final SystemException ex) {
				if (connection.transparent_reconnection) {
		    		try {
                        final DbRedundancy dbr = DbRedundancy.get_instance();
                        final String th2 = dbr.get(connection.url.host + ":" + connection.url.port);

                        // Prepare the connection string
                        final String db_corbaloc = "corbaloc:iiop:" + th2 + "/database";

                        // And connect to database.
                        createDevice(connection, db_corbaloc);
                        // System.out.println("Connected to " + db_corbaloc);
                    } catch (final SystemException e) {
                        // e.printStackTrace();
                        connection.device = null;
                        connection.ior = null;
                        Except.throw_connection_failed("TangoApi_DATABASE_CONNECTION_FAILED",
                            "Connection to database failed  !\n" + e, "connect_to_dbase("
                                + connection.url.host + "," + connection.url.strPort + ")");
 		    		}
				} else {
		    		// e.printStackTrace();
		    		connection.device = null;
		    		connection.ior = null;
    		    	Except.throw_connection_failed("TangoApi_DATABASE_CONNECTION_FAILED",
	    		    	"Connection to database failed  !\n" + ex, "connect_to_dbase("
		    		    	+ connection.url.host + "," + connection.url.strPort + ")");
				}
	    	}
		}
    }
274634
def connection(self):
        
        connection = self._get_connection()
        if connection:
            return connection
        else:
            message = "GTF database needs to be created"
            if self.install_string:
                message += ", run: %s" % self.install_string
            raise ValueError(message)
1041114
public DatabaseMetaData getMetaData() throws SQLException {
        return new CommonDatabaseMetaData.Builder(protocol.getDatabaseType(), this).
                url("jdbc:drizzle://" + protocol.getHost()
                        + ":" + protocol.getPort()
                        + "/" + protocol.getDatabase()).
                username(protocol.getUsername()).
                version(protocol.getServerVersion()).
                databaseProductName(protocol.getDatabaseType().getDatabaseName()).
                build();
    }
362039
def initdb():
    

    print("Syncing up database...")
    cwd_to_sys_path()
    if db and hasattr(db, "Model"):
        db.create_all()
        for m in db.Model.__subclasses__():
            if hasattr(m, "initialize__"):
                print("Sync up model: %s ..." % m.__name__)
                getattr(m, "initialize__")()

    print("Done")
637493
Connection getDataSourceConnection() {
        Connection connection = null;
        try {
            connection = dataSource.getConnection();
        } catch (SQLException ex) {
            throw new InitializationException("Could not obtain the db connection: Cannot get connection", ex);
        }
        return connection;
    }
1220032
def getConnectorVersion(self):
		
		result = asyncResult()
		data = self._getURL("/",versioned=False)
		result.fill(data)
		if data.status_code == 200:
			result.error = False
		else:
			result.error = response_codes("get_mdc_version",data.status_code)
		result.is_done = True
		return result
662410
def get_connection(self):
        
        database = {
            'data': _databases.setdefault(self.identifier, defaultdict(dict)),
            'lock': _locks.setdefault(self.identifier, Lock()),
            'counters': _counters
        }
        return database
691708
protected function createDatabaseDriver()
    {
        $table = $this->app['config']['session.table'];

        $lifetime = $this->app['config']['session.lifetime'];

        return $this->buildSession(new DatabaseSessionHandler(
            $this->getDatabaseConnection(), $table, $lifetime, $this->app
        ));
    }
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);
    }
1114875
public Connection createDBConnection() {
        if (mDBConnInfo != null) {
            return getConnectionViaDriverMangaer(mDBConnInfo.DBDriver, mDBConnInfo.DBUrl, mDBConnInfo.DBUser, mDBConnInfo.DBPassword);
        } else {
            return null;
        }
    }
813979
public synchronized Connection getConnection() throws DatabaseException {
        initialize();
        Connection conn = null;
        try {
            conn = DriverManager.getConnection(connectionString, userName, password);
        } catch (SQLException ex) {
            LOGGER.debug("", ex);
            throw new DatabaseException("Unable to connect to the database", ex);
        }
        return conn;
    }
400028
public function getDefaultDatabase()
    {
        if (!isset($this->_config['database'])) {
            throw new Exception(sprintf('You have not configured a default database for Datasource %s yet.', $this->_config['name']));
        }
        $db = $this->_config['database'];
        return $this->connect()->database($db);
    }
129082
def _connect(self):
        
        if self._connection is not None:
            raise RuntimeError('Close connection first.')
        self._connection = connect(self._database, **self._kwds)
        self._connection.isolation_level = None
575315
private ODatabaseDocument checkAndAcquireConnection() {
        final ODatabaseDocument res;
        if (userManager.isSpecificUser()) {
            // non pool-managed connection for different user
            res = orientDB.get().open(database, userManager.getUser(), userManager.getPassword());
        } else {
            res = pool.acquire();
        }

        if (res.isClosed()) {
            final String message = String.format(
                    "Pool %s return closed connection something is terribly wrong", getType());
            logger.error(message);
            throw new IllegalStateException(message);
        }
        return res;
    }
1174285
def connect(self):
        
        self._connection = StrictRedis(
            host=self._host,
            port=self._port,
            db=self._database,
            password=self._password)