public DatabaseType getDatabaseType() {
    String dbUrl = getDatabaseUrl();
    DatabaseType databaseType;

    if (dbUrl.contains(DatabaseType.POSTGRES.getName())) {
      databaseType = DatabaseType.POSTGRES;
    } else if (dbUrl.contains(DatabaseType.ORACLE.getName())) {
      databaseType = DatabaseType.ORACLE;
    } else if (dbUrl.contains(DatabaseType.MYSQL.getName())) {
      databaseType = DatabaseType.MYSQL;
    } else if (dbUrl.contains(DatabaseType.DERBY.getName())) {
      databaseType = DatabaseType.DERBY;
    } else if (dbUrl.contains(DatabaseType.SQL_SERVER.getName())) {
      databaseType = DatabaseType.SQL_SERVER;
    } else if (dbUrl.contains(DatabaseType.SQL_ANYWHERE.getName())) {
      databaseType = DatabaseType.SQL_ANYWHERE;
    } else if (dbUrl.contains(DatabaseType.H2.getName())) {
      databaseType = DatabaseType.H2;
    } else {
      throw new RuntimeException(
        "The database type could be not determined from the JDBC URL "
          + dbUrl);
    }

    return databaseType;
  }
Gets the type of database by examining the {@link #getDatabaseUrl()} JDBC
URL.

@return the database type (never {@code null}).
@throws RuntimeException
          if there no known database type.
ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java