Init this database and add it to the databaseOwner.
@param databaseOwner My databaseOwner.
@param iDatabaseType The database type (LOCAL/REMOTE).
@param strDBName The database name.
486898
public void init(DatabaseOwner databaseOwner, String strDbName, int iDatabaseType, Map<String, Object> properties)
    {
        super.init(databaseOwner, strDbName, iDatabaseType, properties);

        this.setMasterSlave(RecordOwner.MASTER);      // This is in the client space (Don't execute Server Behaviors)
        
        this.setProperty(DBParams.MESSAGES_TO_REMOTE, DBConstants.FALSE);   // Sent by server version
        this.setProperty(DBParams.CREATE_REMOTE_FILTER, DBConstants.TRUE);  // Yes
        this.setProperty(DBParams.UPDATE_REMOTE_FILTER, DBConstants.FALSE); // Updated by server version
    }
251424
private void assignDataType(DatabaseType databaseType, DataPersister dataPersister) throws SQLException {
		dataPersister = databaseType.getDataPersister(dataPersister, this);
		this.dataPersister = dataPersister;
		if (dataPersister == null) {
			if (!fieldConfig.isForeign() && !fieldConfig.isForeignCollection()) {
				// may never happen but let's be careful out there
				throw new SQLException("Data persister for field " + this
						+ " is null but the field is not a foreign or foreignCollection");
			}
			return;
		}
		this.fieldConverter = databaseType.getFieldConverter(dataPersister, this);
		if (this.isGeneratedId && !dataPersister.isValidGeneratedType()) {
			StringBuilder sb = new StringBuilder();
			sb.append("Generated-id field '").append(field.getName());
			sb.append("' in ").append(field.getDeclaringClass().getSimpleName());
			sb.append(" can't be type ").append(dataPersister.getSqlType());
			sb.append(".  Must be one of: ");
			for (DataType dataType : DataType.values()) {
				DataPersister persister = dataType.getDataPersister();
				if (persister != null && persister.isValidGeneratedType()) {
					sb.append(dataType).append(' ');
				}
			}
			throw new IllegalArgumentException(sb.toString());
		}
		if (fieldConfig.isThrowIfNull() && !dataPersister.isPrimitive()) {
			throw new SQLException("Field " + field.getName() + " must be a primitive if set with throwIfNull");
		}
		if (this.isId && !dataPersister.isAppropriateId()) {
			throw new SQLException("Field '" + field.getName() + "' is of data type " + dataPersister
					+ " which cannot be the ID field");
		}
		this.dataTypeConfigObj = fieldConverter.makeConfigObject(this);
		String defaultStr = fieldConfig.getDefaultValue();
		if (defaultStr == null) {
			this.defaultValue = null;
		} else if (this.isGeneratedId) {
			throw new SQLException("Field '" + field.getName() + "' cannot be a generatedId and have a default value '"
					+ defaultStr + "'");
		} else {
			this.defaultValue = this.fieldConverter.parseDefaultString(this, defaultStr);
		}
	}
562973
public void init(DatabaseOwner databaseOwner, String strDbName, int iDatabaseType, Map<String, Object> properties)
    {
        super.init(databaseOwner, strDbName, iDatabaseType, properties);
        // Typically, JDBC databases do not support locking (Change to "true" otherwise on JDBC open)
        this.setProperty(SQLParams.EDIT_DB_PROPERTY, SQLParams.DB_EDIT_NOT_SUPPORTED);
        m_bAutosequenceSupport = false;     // JDBC databases generally do not support identity, and usually I don't use this capability.
        
        // The following settings are true because JDBC is always running over a LAN (and the server version should send and receive messages).
        this.setProperty(DBParams.MESSAGES_TO_REMOTE, DBConstants.TRUE);   // Sent by server version
        this.setProperty(DBParams.CREATE_REMOTE_FILTER, DBConstants.TRUE);  // Yes, for remote tables
        this.setProperty(DBParams.UPDATE_REMOTE_FILTER, DBConstants.TRUE); // Updated by server version
    }
463971
@Override
   public DatabaseDataType toDatabaseDataType(final Database database) {
      final DatabaseDataType databaseDataType;
      if (database instanceof DerbyDatabase) {
         databaseDataType = new DatabaseDataType("VARCHAR(32672) FOR BIT DATA");
      } else if (database instanceof H2Database) {
         // User's wanting to use a BLOB can use modifySql.
         databaseDataType = new DatabaseDataType("BINARY");
      } else if (database instanceof OracleDatabase) {
         databaseDataType = new DatabaseDataType("SDO_GEOMETRY");
      } else if (database instanceof PostgresDatabase) {
         databaseDataType = new DatabaseDataType(getName(), getParameters());
      } else {
         databaseDataType = new DatabaseDataType("GEOMETRY");
      }
      return databaseDataType;
   }
997967
public void init(BaseDatabase database, Record record)
    {
        super.init(database, record);

        // Call super to set the table property (without calling remote).
        super.setProperty(DBParams.SUPRESSREMOTEDBMESSAGES, DBConstants.TRUE);
    }
161566
public void setupJDBCConnection(String strJdbcDriver) throws DBException
    {
        if (m_JDBCConnection != null)
            return;

        if (firstTime == null)
        	firstTime = new Date();
    	if (m_classDB == null)
    	{
	        synchronized (firstTime)
	        {
	        	if (m_classDB == null)
	        		m_classDB = ClassServiceUtility.getClassService().makeObjectFromClassName(strJdbcDriver);
	        }
    	}
        Utility.getLogger().info("Driver found: " + (m_classDB != null));
        m_JDBCConnection = this.getJDBCConnection();    // Setup the initial connection
    }
962915
static void initializeDatabaseDriver(String databaseType) {
    String driverClass = System.getProperty(JDBC_DRIVER_CLASS_KEY_PREFIX + databaseType);
    if (driverClass != null) {
      Log.debug("Loading " + driverClass + " to initialize database of type " + databaseType);
      try {
        Class.forName(driverClass);
      } catch (ClassNotFoundException e) {
        throw new RuntimeException("Connection to '" + databaseType + "' database is not possible due to missing JDBC driver. " +
                "User specified driver class: " + driverClass, e);
      }
      return;
    }
    // use built-in defaults
    switch (databaseType) {
      case HIVE_DB_TYPE:
        try {
          Class.forName(HIVE_JDBC_DRIVER_CLASS);
        } catch (ClassNotFoundException e) {
          throw new RuntimeException("Connection to HIVE database is not possible due to missing JDBC driver.", e);
        }
        break;
      case NETEZZA_DB_TYPE:
        try {
          Class.forName(NETEZZA_JDBC_DRIVER_CLASS);
        } catch (ClassNotFoundException e) {
          throw new RuntimeException("Connection to Netezza database is not possible due to missing JDBC driver.", e);
        }
        break;
      default:
        //nothing to do
    }
  }
165908
@Override
	@Deprecated
	public DataSource dataSourceByName(String dbName) {
		return new com.danidemi.jlubricant.embeddable.BasicDataSource(
				dbByName(dbName));
	}
250588
public void deleteDB(String dbName) {
        assertNotEmpty(dbName, "dbName");
        delete(new DatabaseURIHelper(getBaseUri(), dbName).getDatabaseUri());

    }
865252
public void setDBProperties(Map<String, Object> properties) throws DBException, RemoteException
    {
        BaseTransport transport = this.createProxyTransport(SET_DB_PROPERTIES);
        transport.addParam(PROPERTIES, properties);
        Object strReturn = transport.sendMessageAndGetReply();
        Object objReturn = transport.convertReturnObject(strReturn);
        this.checkDBException(objReturn);
    }
867729
public static boolean registerJdbcDataSource(String name, DataSource dataSource) {
        return jdbcDataSources.putIfAbsent(name, dataSource) == null;
    }
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);
	}
603436
public void init(BaseDatabase database, Record record)
    {
        m_pTable = null;
        super.init(database, record);
        m_pTable = ((PhysicalDatabase)database).getPDatabase().getPTable(record, true);
        m_pTable.addPTableOwner(this);
    }
1041207
public int insert(DatabaseType databaseType, DatabaseConnection databaseConnection, T data, ObjectCache objectCache)
			throws SQLException {
		KeyHolder keyHolder = null;
		if (idField != null) {
			boolean assignId;
			if (idField.isAllowGeneratedIdInsert() && !idField.isObjectsFieldValueDefault(data)) {
				assignId = false;
			} else {
				assignId = true;
			}
			if (idField.isSelfGeneratedId() && idField.isGeneratedId()) {
				if (assignId) {
					idField.assignField(connectionSource, data, idField.generateId(), false, objectCache);
				}
			} else if (idField.isGeneratedIdSequence() && databaseType.isSelectSequenceBeforeInsert()) {
				if (assignId) {
					assignSequenceId(databaseConnection, data, objectCache);
				}
			} else if (idField.isGeneratedId()) {
				if (assignId) {
					// get the id back from the database
					keyHolder = new KeyHolder(idField.getColumnName());
				}
			} else {
				// the id should have been set by the caller already
			}
		}

		try {
			// implement {@link DatabaseField#foreignAutoCreate()}, need to do this _before_ getFieldObjects() below
			if (tableInfo.isForeignAutoCreate()) {
				for (FieldType fieldType : tableInfo.getFieldTypes()) {
					if (!fieldType.isForeignAutoCreate()) {
						continue;
					}
					// get the field value
					Object foreignObj = fieldType.extractRawJavaFieldValue(data);
					if (foreignObj != null && fieldType.getForeignIdField().isObjectsFieldValueDefault(foreignObj)) {
						fieldType.createWithForeignDao(foreignObj);
					}
				}
			}

			Object[] args = getFieldObjects(data);
			Object versionDefaultValue = null;
			// implement {@link DatabaseField#version()}
			if (versionFieldTypeIndex >= 0 && args[versionFieldTypeIndex] == null) {
				// if the version is null then we need to initialize it before create
				FieldType versionFieldType = argFieldTypes[versionFieldTypeIndex];
				versionDefaultValue = versionFieldType.moveToNextValue(null);
				args[versionFieldTypeIndex] = versionFieldType.convertJavaFieldToSqlArgValue(versionDefaultValue);
			}

			int rowC;
			try {
				rowC = databaseConnection.insert(statement, args, argFieldTypes, keyHolder);
			} catch (SQLException e) {
				// NOTE: don't log full exception here
				logger.debug("insert data with statement '{}' and {} args, threw exception: {}", statement, args.length,
						e);
				if (args.length > 0) {
					// need to do the (Object) cast to force args to be a single object
					logger.trace("insert arguments: {}", (Object) args);
				}
				throw e;
			}
			logger.debug("insert data with statement '{}' and {} args, changed {} rows", statement, args.length, rowC);
			if (args.length > 0) {
				// need to do the (Object) cast to force args to be a single object
				logger.trace("insert arguments: {}", (Object) args);
			}
			if (rowC > 0) {
				if (versionDefaultValue != null) {
					argFieldTypes[versionFieldTypeIndex].assignField(connectionSource, data, versionDefaultValue, false,
							null);
				}
				if (keyHolder != null) {
					// assign the key returned by the database to the object's id field after it was inserted
					Number key = keyHolder.getKey();
					if (key == null) {
						// may never happen but let's be careful out there
						throw new SQLException(
								"generated-id key was not set by the update call, maybe a schema mismatch between entity and database table?");
					}
					if (key.longValue() == 0L) {
						// sanity check because the generated-key returned is 0 by default, may never happen
						throw new SQLException(
								"generated-id key must not be 0 value, maybe a schema mismatch between entity and database table?");
					}
					assignIdValue(data, key, "keyholder", objectCache);
				}
				/*
				 * If we have a cache and if all of the foreign-collection fields have been assigned then add to cache.
				 * However, if one of the foreign collections has not be assigned then don't add it to the cache.
				 */
				if (objectCache != null && foreignCollectionsAreAssigned(tableInfo.getForeignCollections(), data)) {
					Object id = idField.extractJavaFieldValue(data);
					objectCache.put(clazz, id, data);
				}
			}

			return rowC;
		} catch (SQLException e) {
			throw SqlExceptionUtil.create("Unable to run insert stmt on object " + data + ": " + statement, e);
		}
	}
986593
@Override
  public final void changeDatabase(final String pDbName) throws Exception {
    String dbNm = this.databasePrefix + pDbName + ".sqlite";
    synchronized (this.factoryAppBeans) {
      if (!this.factoryAppBeans.getDatabaseName().equals(dbNm)) {
        this.factoryAppBeans.setDatabaseName(dbNm);
        this.factoryAppBeans.handleDatabaseChanged();
      }
    }
  }
1313350
function registerDatabaseType($typeIdentifier, \Plasma\Types\TypeExtensionInterface $type): void {
        if(isset($this->dbTypes[$typeIdentifier])) {
            throw new \Plasma\Exception('Database Type identifier is already in use');
        }
        
        $this->dbTypes[$typeIdentifier] = $type;
    }
285971
public Database getDatabase(String strDBName, int iDatabaseType, Map<String, Object> properties)
    {
        if ((strDBName == null) || (strDBName.length() == 0))
            return null;
        Database database = this.getDatabaseList(iDatabaseType).get(strDBName);
        if (database == null)
        {
            if ((properties != null)
            	&& (DBConstants.FALSE.equals(properties.get(DBConstants.CREATE_DB_IF_NOT_FOUND)))
            	&& (Environment.DATABASE_DOESNT_EXIST == ((Environment)m_databaseOwner.getEnvironment()).getCachedDatabaseProperties(strDBName)))
            		return null;	// Hey, if the database doesn't exist, don't try again.
            if (iDatabaseType != DBConstants.SCREEN)
                database = this.makeDatabase(iDatabaseType);    // BaseDatabase not found, open it!
            else
                database = new BaseDatabase();                  // Special case: A screen database
            if (database != null)
                database.init(m_databaseOwner, strDBName, iDatabaseType & DBConstants.TABLE_MASK, properties); // init it!
            if (database != null)
            {
                try   {
                    ((BaseDatabase)database).open();    // open it!
                } catch (DBException ex) {
                    database.free();
                    database = null;    // Failure on db open
                    if ((ex.getErrorCode() == DBConstants.DB_NOT_FOUND)
                		&& (properties != null)
                        && (DBConstants.FALSE.equals(properties.get(DBConstants.CREATE_DB_IF_NOT_FOUND))))
                    {	// If the db doesn't exist, cache the name so I won't try this (expensive) operation again
                        ((Environment)m_databaseOwner.getEnvironment()).cacheDatabaseProperties(strDBName, Environment.DATABASE_DOESNT_EXIST);
                    }
                }
            }
        }
        return database;
    }