Given the name, either get the open database, or open a new one.
@param strDBName The name of the database.
@param iDatabaseType The type of database/table.
@return The database (new or current).
513135
public Database getDatabase(String strDBName, int iDatabaseType, Map<String, Object> properties)
    {
        return m_databaseCollection.getDatabase(strDBName, iDatabaseType, properties);
    }
1124619
public String getDatabaseName(boolean bPhysicalName)
    {
        String strDbName = m_strDbName;
        if (bPhysicalName)
        {
            if ((this.getDatabaseType() & DBConstants.SYSTEM_DATABASE) != DBConstants.SYSTEM_DATABASE)
            {
                if ((this.getProperty(strDbName + DBSHARED_PARAM_SUFFIX) != null)
                    && (!m_strDbName.equalsIgnoreCase(this.getProperty(SQLParams.INTERNAL_DB_NAME)))
                    && ((this.getDatabaseType() & DBConstants.TABLE_DATA_TYPE_MASK) == DBConstants.SHARED_DATA))
                        strDbName = this.getProperty(strDbName + DBSHARED_PARAM_SUFFIX);	// Special processing - db name supplied
                else if ((this.getProperty(strDbName + DBUSER_PARAM_SUFFIX) != null)
                    && (!m_strDbName.equalsIgnoreCase(this.getProperty(SQLParams.INTERNAL_DB_NAME)))
                    && ((this.getDatabaseType() & DBConstants.TABLE_DATA_TYPE_MASK) == DBConstants.USER_DATA))
                        strDbName = this.getProperty(strDbName + DBUSER_PARAM_SUFFIX);	// Special processing - db name supplied
                else
                {
	                if (this.getProperty(DBConstants.DB_USER_PREFIX) != null)
	                    if (!m_strDbName.equalsIgnoreCase(this.getProperty(SQLParams.INTERNAL_DB_NAME)))
	                        if ((this.getDatabaseType() & DBConstants.TABLE_DATA_TYPE_MASK) == DBConstants.USER_DATA)
	                    		strDbName = Utility.addToPath(this.getProperty(DBConstants.DB_USER_PREFIX), strDbName, DB_NAME_SEPARATOR);    // User prefix - Only for user data
	                if (Utility.getSystemSuffix(this.getProperty(DBConstants.SYSTEM_NAME), this.getProperty(DBConstants.DEFAULT_SYSTEM_NAME)) != null)
	                    if (!m_strDbName.equalsIgnoreCase(this.getProperty(SQLParams.INTERNAL_DB_NAME)))
	                    {
	                        if ((this.getDatabaseType() & DBConstants.TABLE_DATA_TYPE_MASK) == DBConstants.USER_DATA)
	                        	strDbName = Utility.addToPath(strDbName, Utility.getSystemSuffix(this.getProperty(DBConstants.SYSTEM_NAME), this.getProperty(DBConstants.DEFAULT_SYSTEM_NAME)), DB_NAME_SEPARATOR);	 // System suffix
	                        else if ((this.getDatabaseType() & DBConstants.TABLE_DATA_TYPE_MASK) == DBConstants.SHARED_DATA)
	                        {  // The shared database name is never changed, EXCEPT if the mode is set. Then there are a few exceptions
	                            if ((this.getProperty(DBConstants.MODE) == null) || (this.getProperty(DBConstants.MODE).length() == 0) || (this.getProperty(DBConstants.MODE).equalsIgnoreCase(RUN_MODE)))
                                {  // Default = Regular (run) mode
                                    if ((DEV_DATABASE.equalsIgnoreCase(m_strDbName)) || (MAIN_DATABASE.equalsIgnoreCase(m_strDbName)))
                                        strDbName = Utility.addToPath(strDbName, Utility.getSystemSuffix(this.getProperty(DBConstants.SYSTEM_NAME), this.getProperty(DBConstants.DEFAULT_SYSTEM_NAME)), DB_NAME_SEPARATOR);  // Add System suffix
                                }
                                else
                                {   // Development mode
                                    if (this.getProperty(DBConstants.MODE).length() >= 3)
	                                    if (this.getProperty(DBConstants.MODE).substring(0, 3).equalsIgnoreCase(DEVELOPMENT_MODE))
	                                {
	                                    if (DEV_DATABASE.equalsIgnoreCase(m_strDbName))
                                            strDbName = Utility.addToPath(strDbName, Utility.getSystemSuffix(this.getProperty(DBConstants.SYSTEM_NAME), this.getProperty(DBConstants.DEFAULT_SYSTEM_NAME)), DB_NAME_SEPARATOR);  // System suffix	                                        
	                                    if (MAIN_DATABASE.equalsIgnoreCase(m_strDbName))
	                                        strDbName = Utility.addToPath(strDbName, DEV_MAIN_SUFFIX, DB_NAME_SEPARATOR);  // Development menus
	                                }
                                }
	                        }
	                    }
                }
//x                if (this.getLocale() != null) //**THIS IS DONE IN makeDBLocale**
//x                	if ((this.getDatabaseType() & DBConstants.TABLE_DATA_TYPE_MASK) == DBConstants.SHARED_DATA)
//x                		if (this.getLocale() != this.getProperty(DBConstants.SYSTEM_NAME))
//x                			strDbName = strDbName + '_' + this.getLocale();
                if ((this.getDatabaseType() & DBConstants.TABLE_DATA_TYPE_MASK) == DBConstants.USER_DATA)
                    strDbName = Utility.addToPath(strDbName, USER_SUFFIX, DB_NAME_SEPARATOR);
                else if ((this.getDatabaseType() & DBConstants.TABLE_DATA_TYPE_MASK) == DBConstants.SHARED_DATA)
                    strDbName = Utility.addToPath(strDbName, SHARED_SUFFIX, DB_NAME_SEPARATOR);
            }
        }
        return strDbName;
    }
910986
@InterfaceAudience.Public
    public List<String> getAllDatabaseNames() {
        String[] databaseFiles = directoryFile.list(new FilenameFilter() {

            @Override
            public boolean accept(File dir, String filename) {
                if (filename.endsWith(Manager.kDBExtension)) {
                    return true;
                }
                return false;
            }
        });
        List<String> result = new ArrayList<String>();
        for (String databaseFile : databaseFiles) {
            String trimmed = databaseFile.substring(0, databaseFile.length() - Manager.kDBExtension.length());
            String replaced = trimmed.replace(':', '/');
            result.add(replaced);
        }
        Collections.sort(result);
        return Collections.unmodifiableList(result);
    }
943667
@Override
	public JdbcDatabaseDescriptor dbByName(final String dbName) {
		Collection<H2DatabaseWorking> select = CollectionUtils.select(dbsw, new Predicate<H2DatabaseWorking>() {

			@Override
			public boolean evaluate(H2DatabaseWorking db) {
				return dbName.equals( db.getName() );
			}

		});
		if(CollectionUtils.size(select)==0){
			throw new IllegalArgumentException("There are no databases called '" + dbName + "'");
		}
		if(CollectionUtils.size(select)>=2){
			throw new IllegalArgumentException("More than one database is called '" + dbName + "'");
		}
		return CollectionUtils.extractSingleton( select );
	}
376595
@Override
	public void createDb(String dbName) {
		String dbPath = getDbPath(dbName);
		if (map.containsKey(dbPath)) {
			throw DBLogger.newUser("Database already exists: " + dbPath);
		}
		map.put(dbPath, new ArrayList<ByteBuffer>());
		
		//create files

		//DB file
		FreeSpaceManager fsm = new FreeSpaceManager();
		StorageRootInMemory root = 
				new StorageRootInMemory(dbPath, "rw", ZooConfig.getFilePageSize(), fsm);
		IOResourceProvider file = root.createChannel();
		StorageChannelOutput out = file.createWriter(false);
		fsm.initBackingIndexNew(file);

		int headerPage = out.allocateAndSeek(PAGE_TYPE.DB_HEADER, 0);
		if (headerPage != 0) {
			throw DBLogger.newFatalInternal("Header page = " + headerPage);
		}
		int rootPage1 = out.allocateAndSeek(PAGE_TYPE.ROOT_PAGE, 0);
		int rootPage2 = out.allocateAndSeek(PAGE_TYPE.ROOT_PAGE, 0);

		//header: this is written further down

		//write User data
		int userData = out.allocateAndSeek(PAGE_TYPE.USERS, 0);

		//dir for schemata
		int schemaData = out.allocateAndSeekAP(PAGE_TYPE.SCHEMA_INDEX, 0, -1);
		//ID of next page
		out.writeInt(0);
		//Schema ID / schema data (page or actual data?)
		//0 for no more schemata
		out.writeInt(0);


		//dir for indices
		int indexDirPage = out.allocateAndSeek(PAGE_TYPE.INDEX_CATALOG, 0);
		//ID of next page
		out.writeInt(0);
		//Schema ID / attribute ID / index type / Page ID
		//0 for nor more indices
		out.writeInt(0);

		//OID index
		PagedOidIndex oidIndex = new PagedOidIndex(file);
		int oidPage = file.writeIndex(oidIndex::write);

		//Free space index
		int freeSpacePg = file.writeIndex(fsm::write);
		
		//write header
		out.seekPageForWrite(PAGE_TYPE.DB_HEADER, headerPage);
		out.writeInt(DiskIO.DB_FILE_TYPE_ID);
		out.writeInt(DiskIO.DB_FILE_VERSION_MAJ);
		out.writeInt(DiskIO.DB_FILE_VERSION_MIN);
		out.writeInt(ZooConfig.getFilePageSize());
		out.writeInt(rootPage1);
		out.writeInt(rootPage2);

		writeRoot(out, rootPage1, 1, userData, oidPage, schemaData, indexDirPage, freeSpacePg, 
				fsm.getPageCount());
		writeRoot(out, rootPage2, 0, userData, oidPage, schemaData, indexDirPage, freeSpacePg, 
				fsm.getPageCount());

		file.close();
		file = null;
		root.close();
		root = null;
		out = null;


		//initial schemata
		Properties props = new ZooJdoProperties(dbName);
		PersistenceManagerFactory pmf = 
			JDOHelper.getPersistenceManagerFactory(props);
		PersistenceManager pm = pmf.getPersistenceManager();
		pm.currentTransaction().begin();

		ZooSchema schema = ZooJdoHelper.schema(pm);
		schema.addClass(PersistenceCapableImpl.class);
		schema.addClass(DBHashMap.class);
		schema.addClass(DBArrayList.class);

		pm.currentTransaction().commit();
		pm.close();
		pmf.close();
	}
957888
static synchronized SQLiteDatabase getDatabase() {
        if(sInstance == null) {
           throw new SprinklesNotInitializedException();
        }

        if(sDatabase == null) {
            DbOpenHelper dbOpenHelper = new DbOpenHelper(sInstance.mContext, sInstance.databaseName, sInstance.initialDatabaseVersion);
            sDatabase = dbOpenHelper.getWritableDatabase();
        }

        return sDatabase;
    }
76104
protected Table getTableFromDB(String tableName) {
        Table table = m_db.getTables().getExact(tableName);
        return table;
    }
195573
function getDatabase(index, opts) {
  var db;
  if(!this._databases[index]) {
    db = new Database(this, opts);
    this._databases[index] = db;
  }
  return this._databases[index];
}
1074373
public function getDatabase($databaseName = null) {
		if ($databaseName === null) {
			$databaseName = $this->dbname;
		}

		if (! isset($this->databases[$databaseName])) {
			$this->databases[$databaseName] = $this->getClient()->selectDB($databaseName);
		}

		return $this->databases[$databaseName];
	}
773132
@Override
  public final void createDatabase(final String pDbName,
    final int pDbId) throws Exception {
    String dbNm = this.databasePrefix + pDbName + ".sqlite";
    synchronized (this.factoryAppBeans) {
      if (!this.factoryAppBeans.getDatabaseName().equals(dbNm)) {
        this.factoryAppBeans.setDatabaseName(dbNm);
        this.factoryAppBeans.setNewDatabaseId(pDbId);
        this.factoryAppBeans.handleDatabaseChanged();
      }
    }
  }
941996
public String determineDatabaseName() {
		if (this.generateUniqueName) {
			if (this.uniqueName == null) {
				this.uniqueName = UUID.randomUUID().toString();
			}
			return this.uniqueName;
		}
		if (StringUtils.hasLength(this.name)) {
			return this.name;
		}
		if (this.embeddedDatabaseConnection != EmbeddedDatabaseConnection.NONE) {
			return "testdb";
		}
		return null;
	}
528581
public String getDatabasePrefix(int iDatabaseType)
    {
        int iDBType = (iDatabaseType & DBConstants.TABLE_TYPE_MASK);
        String strDbPrefix = null;
        if (iDBType == DBConstants.LOCAL)
            strDbPrefix = this.getProperty(DBParams.LOCAL);
        else if (iDBType == DBConstants.REMOTE)
            strDbPrefix = this.getProperty(DBParams.REMOTE);
        else if (iDBType == DBConstants.TABLE)
            strDbPrefix = this.getProperty(DBParams.TABLE);
        else if (iDBType == DBConstants.MEMORY)
            strDbPrefix = DBParams.MEMORY;
        else if (iDBType == DBConstants.UNSHAREABLE_MEMORY)
            strDbPrefix = DBParams.MEMORY;
        else if (iDBType == DBConstants.SYSTEM_DATABASE)
            strDbPrefix = this.getProperty(DBParams.REMOTE);
        else if (iDBType == DBConstants.REMOTE_MEMORY)
        {
            strDbPrefix = this.getProperty(DBParams.REMOTE);    // Client for remote, memory for concrete db
            if ((strDbPrefix == null) || (this.isConcreteDBClass(strDbPrefix)))
                strDbPrefix = DBParams.MEMORY;
        }
        if ((iDatabaseType & DBConstants.MAPPED) != 0)
            if (this.isConcreteDBClass(strDbPrefix))
                strDbPrefix = "Mapped";
        return strDbPrefix;
    }
294051
public void open() throws DBException
    {
        if (m_pDatabase == null)
        {
            PhysicalDatabaseParent pDBParent = null;
            Environment env = (Environment)this.getDatabaseOwner().getEnvironment();
            if (env != null)
                pDBParent = (PhysicalDatabaseParent)env.getPDatabaseParent(mapDBParentProperties, true);
            String databaseName = this.getDatabaseName(true);
            if (databaseName.endsWith(BaseDatabase.SHARED_SUFFIX))
                databaseName = databaseName.substring(0, databaseName.length() - BaseDatabase.SHARED_SUFFIX.length());
            else if (databaseName.endsWith(BaseDatabase.USER_SUFFIX))
                databaseName = databaseName.substring(0, databaseName.length() - BaseDatabase.USER_SUFFIX.length());
            char strPDatabaseType = this.getPDatabaseType();
            m_pDatabase = pDBParent.getPDatabase(databaseName, strPDatabaseType, false);
            if (m_pDatabase == null)
                m_pDatabase = this.makePDatabase(pDBParent, databaseName);
            m_pDatabase.addPDatabaseOwner(this);
        }
        m_pDatabase.open();
        
        super.open(); // Do any inherited
    }
181732
String getDatabaseName(String dbName) {
        if (mFileNameMap == null) {
            return null;
        }
        String name = mFileNameMap.get(dbName);
        if (name == null && dbName != null) {
            name = mFileNameMap.get(null);
        }
        if (name == null) {
            return null;
        }
        if (mDatabaseHook != null) {
            try {
                dbName = mDatabaseHook.databaseName(dbName);
            } catch (IncompatibleClassChangeError e) {
                // Method not implemented.
            }
        }
        return dbName;
    }
1328974
public static dbdbprofile get(nitro_service service, String name) throws Exception{
		dbdbprofile obj = new dbdbprofile();
		obj.set_name(name);
		dbdbprofile response = (dbdbprofile) obj.get_resource(service);
		return response;
	}
531038
public static DatabaseType createDatabaseType(String databaseUrl) {
		String dbTypePart = extractDbType(databaseUrl);
		for (DatabaseType databaseType : databaseTypes) {
			if (databaseType.isDatabaseUrlThisType(databaseUrl, dbTypePart)) {
				return databaseType;
			}
		}
		throw new IllegalArgumentException("Unknown database-type url part '" + dbTypePart + "' in: " + databaseUrl);
	}
148990
public void init(DatabaseOwner databaseOwner, String strDbName, int iDatabaseType, Map<String, Object> properties)
    {
        super.init(databaseOwner, strDbName, iDatabaseType, properties);
        m_pDatabase = null;
    }