public Database build(Configuration conf) throws MetaException {
    if (name == null) throw new MetaException("You must name the database");
    if (catalogName == null) catalogName = MetaStoreUtils.getDefaultCatalog(conf);
    Database db = new Database(name, description, location, params);
    db.setCatalogName(catalogName);
    db.setCreateTime(createTime);
    if (managedLocation != null)
      db.setManagedLocationUri(managedLocation);
    try {
      if (ownerName == null) ownerName = SecurityUtils.getUser();
      db.setOwnerName(ownerName);
      if (ownerType == null) ownerType = PrincipalType.USER;
      db.setOwnerType(ownerType);
      if (type == null) {
        type = DatabaseType.NATIVE;
        if (connectorName != null || remoteDBName != null) {
          throw new MetaException("connector name or remoteDBName cannot be set for database of type NATIVE");
        }
      } else if (type == DatabaseType.REMOTE) {
        if (connectorName == null)
          throw new MetaException("connector name cannot be null for database of type REMOTE");
        db.setConnector_name(connectorName);
        if (remoteDBName != null) {
          db.setRemote_dbname(remoteDBName);
        }
      }
      db.setType(type);
      return db;
    } catch (IOException e) {
      throw MetaStoreUtils.newMetaException(e);
    }
  }
A builder for {@link Database}.  The name of the new database is required.  Everything else
selects reasonable defaults.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/client/builder/DatabaseBuilder.java