private int getNextCatalogId(Statement stmt) throws SQLException, HiveMetaException {
    String query = schemaTool.quote(NEXT_CATALOG_ID_QUERY);
    LOG.debug("Going to run " + query);
    try (ResultSet rs = stmt.executeQuery(query)) {
      if (!rs.next()) {
        throw new HiveMetaException("No catalogs found, have you upgraded the database?");
      }
      int nextId = rs.getInt(1) + 1;
      // We need to stay out of the way of any sequences used by the underlying database.
      // Otherwise the next time the client tries to add a catalog we'll get an error.
      // There should never be billions of catalogs, so we'll shift our sequence number up
      // there to avoid clashes.
      int floor = 1 << 30;
      return Math.max(nextId, floor);
    }
  }
Print Hive version and schema version.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/tools/schematool/SchemaToolTaskCreateCatalog.java