Constructor.
@param pDatabaseOwner The raw data database owner (optional).
@param strDBName The database name (The key for lookup).
@param charPDatabaseType The database type.
483239
public void init(PhysicalDatabaseParent pDatabaseOwner, String strDbName, char charPDatabaseType)
    {
        m_htTableList = new Hashtable<Object,PTable>();
        m_strDBName = strDbName;
        m_charPDatabaseType = charPDatabaseType;
        this.setPDatabaseParent(pDatabaseOwner);
    }
947742
public boolean create(String strDatabaseName) throws DBException
    {
        try {
            String strDBName = this.getProperty(SQLParams.INTERNAL_DB_NAME);
            int iDatabaseType = DBConstants.SYSTEM_DATABASE;
            DatabaseOwner env = this.getDatabaseOwner();
            JdbcDatabase db = (JdbcDatabase)env.getDatabase(strDBName, iDatabaseType, null);    // Do NOT pass properties when opening system database
            Statement queryStatement = db.getJDBCConnection().createStatement();

            String strSQL = "create database " + strDatabaseName + ";";
            queryStatement.execute(strSQL);
            queryStatement.close();
            db.free();

            String oldValue = this.getProperty(DBConstants.CREATE_DB_IF_NOT_FOUND);
            this.setProperty(DBConstants.CREATE_DB_IF_NOT_FOUND, DBConstants.FALSE);
            
            this.close();   // Since I don't know what kind of connection this is.
            this.setupDBConnection();

            this.setProperty(DBConstants.CREATE_DB_IF_NOT_FOUND, oldValue);
            
            if (this.getProperty(DBConstants.LOAD_INITIAL_DATA) != null)
            	if ((this.getDatabaseType() & (DBConstants.SHARED_DATA | DBConstants.USER_DATA)) == DBConstants.SHARED_DATA)	// Yes, only shared data can have DatabaseInfo
            {
                DatabaseInfo recDatabaseInfo = new DatabaseInfo();
                try {
                	recDatabaseInfo.setDatabaseName(this.getDatabaseName(false));
                	recDatabaseInfo.setTable(this.doMakeTable(recDatabaseInfo));    // This makes a jdbc table
                	recDatabaseInfo.init(null); // This should create the table if an archive exists
                } catch (Exception ex) {
                	// Ignore
                } finally {
                	recDatabaseInfo.free();
                }
            }
            return true;    // Success
        } catch (SQLException ex) {
            ex.printStackTrace();
        }

        return super.create(strDatabaseName);   // Error, not found
    }
597605
public void init(BaseDatabase database, Record record)
    {
        super.init(database, record);
        
        m_databaseFake = m_database;
        m_database = this.getSharedTable().getDatabase();  // Return the correct database
    }
327230
public function updatePrimaryDbValueFromDbData()
    {
        $dbDataPrimaryValue = $this->getDbDataPrimaryValue();

        if ($dbDataPrimaryValue !== $this->getDbDataPrimaryDefaultValue()) {
            $this->setPrimaryDbValue($dbDataPrimaryValue);
        }
    }
1339133
public void addPDatabase(PDatabase pDatabase)
    {
        Object strKey = pDatabase.getDatabaseKey();
        m_htDBList.put(strKey, pDatabase);
    }
518936
@Override
	public HsqlDatabaseDescriptor dbByName(final String dbName) {
		Collection<HsqlDatabaseDescriptor> select = CollectionUtils.select(dbs,
				new Predicate<HsqlDatabaseDescriptor>() {

					@Override
					public boolean evaluate(HsqlDatabaseDescriptor db) {
						return dbName.equals(db.getDbName());
					}

				});
		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);
	}
920383
private DbDatum[] get_obj_property(Database database, String name, String type, DbDatum[] properties)
            throws DevFailed {
        if (!database.isAccess_checked()) checkAccess(database);

        //	Format input parameters as string array
        //--------------------------------------------
        String[] array;
        array = new String[properties.length];
        for (int i = 0 ; i<properties.length ; i++)
            array[i] = properties[i].name;
        return get_obj_property(database, name, type, array);
    }
22124
public function createDb($sDbName)
    {
        try {
            $this->execSql("CREATE DATABASE `$sDbName` CHARACTER SET utf8 COLLATE utf8_general_ci;");
            $this->connectDb($sDbName);
        } catch (Exception $e) {
            $oSetup = $this->getInstance("Setup");
            $oSetup->setNextStep($oSetup->getStep('STEP_DB_INFO'));
            throw new Exception(sprintf($this->getInstance("Language")->getText('ERROR_COULD_NOT_CREATE_DB'), $sDbName) . " - " . $e->getMessage(), $e->getCode(), $e);
        }
    }
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();
	}
98995
public function createDatabase($name, $charSet = null) {
		if ($charSet === null) {
			$charSet = self::DEFAULT_CHARACTER_SET;
		}

		$stmt = StringUtils::format(self::CREATE_DB_STMT, [
			'name' => $name,
			'charSet' => $charSet
		]);

		$this->db->exec($stmt);
	}
1280385
public String fixDatabaseProductName(String strDatabaseProductName)
    {
    	if (strDatabaseProductName == null)
    		return null;
    	if (strDatabaseProductName.lastIndexOf(' ') != -1)
    		strDatabaseProductName = strDatabaseProductName.substring(strDatabaseProductName.lastIndexOf(' ') + 1);
    	return strDatabaseProductName.toLowerCase();
    }
1300028
public void init(DatabaseOwner databaseOwner, String strDbName, int iDatabaseType, Map<String, Object> properties)
    {
        super.init(databaseOwner, strDbName, iDatabaseType, properties);

        if ((iDatabaseType & Constants.REMOTE_MEMORY) == 0)
        {   // Usually don't send messages (unless this is a remote copy, then I would)
            this.setProperty(DBParams.MESSAGES_TO_REMOTE, DBConstants.FALSE);   // Send by server version
            this.setProperty(DBParams.CREATE_REMOTE_FILTER, DBConstants.FALSE); // Create the remote filter
            this.setProperty(DBParams.UPDATE_REMOTE_FILTER, DBConstants.FALSE); // Updated by server version
        }
    }
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 );
	}
355802
public void init(DatabaseOwner databaseOwner, String strDbName, int iDatabaseType, Map<String, Object> properties)
    {
        m_databaseOwner = databaseOwner;
        m_strDbName = strDbName;
        m_iDatabaseType = iDatabaseType;
        m_vTableList = new Vector<BaseTable>();
        m_iMasterSlave = RecordOwner.MASTER | RecordOwner.SLAVE;
        m_bAutosequenceSupport = true;
        if (m_properties == null)
            m_properties = new Hashtable<String,Object>();
        if (properties != null)
        	m_properties.putAll(properties);

        m_databaseOwner.addDatabase(this);
    }
626105
public void cacheDatabaseProperties(String strDBName, Map<String,String> map)
    {
        m_mapDBProperties.put(strDBName, map);   // Cache for next time
    }
334342
public boolean setupDataSourceConnection(String strDataSource) throws DBException
    {
        if (m_JDBCConnection != null)
            return true;
        if ((DBConstants.TRUE.equalsIgnoreCase(this.getProperty(DBParams.SERVLET)))
                || ((this.getDatabaseOwner() != null) && (DBConstants.TRUE.equalsIgnoreCase(this.getDatabaseOwner().getEnvironment().getProperty(DBParams.SERVLET)))))
        {   // Datasource connections are only for servlets (NOTE: Letting this code run otherwise messes stuff up)
            try {
                if (m_initialContext == null)
                    m_initialContext = new InitialContext();
                String strDatabaseName = this.getDatabaseName(true);
                strDataSource = Utility.replace(strDataSource, "${dbname}", strDatabaseName);
                DataSource ds = (DataSource)m_initialContext.lookup(strDataSource);
                if (ds == null)
                    return false;   // Failure
                m_JDBCConnection = ds.getConnection();
            } catch (NamingException e) {
                return false;   // Failure
            } catch (SQLException e) {
                return false;   // Failure
            } catch (NoClassDefFoundError e) {
                return false;   // Failure
            } catch (Exception e) {
                return false;   // Failure
            }
            return true;    // Success!
        }
        else
            return false;   // Not supported
    }
451361
function IDBDatabase(db, name, version, storeProperties){
        this.__db = db;
        this.__closed = false;
        this.version = version;
        this.name = name;
        this.onabort = this.onerror = this.onversionchange = null;

        this.__objectStores = {};
        this.objectStoreNames = new idbModules.util.StringList();
        for (var i = 0; i < storeProperties.rows.length; i++) {
            var store = new idbModules.IDBObjectStore(storeProperties.rows.item(i));
            this.__objectStores[store.name] = store;
            this.objectStoreNames.push(store.name);
        }
    }