code: private String findNextSchemaName() throws SQLException {
  
          ResultSet rset = null;
          try {
              // Find next available schema name.
              PreparedStatement ps = getPreparedStatement(SELECT_KAM_CATALOG_SQL);
              rset = ps.executeQuery();
              int maxId = 0;
              while (rset.next()) {
                  // read schemaName value, skip if it does not look like a
                  // schema prefix
                  String schema = rset.getString(5);
                  if (schema == null || !schema.startsWith(kamSchemaPrefix)) {
                      continue;
                  }
  
                  // extract the schema number
                  String id = schema.substring(schema.indexOf(kamSchemaPrefix)
                          + kamSchemaPrefix.length());
  
                  // if the schema number is numeric, compare to current max
                  if (StringUtils.isNumeric(id)) {
                      maxId = Math.max(Integer.parseInt(id), maxId);
                  }
              }
              String schemaName = kamSchemaPrefix + (++maxId);
              return schemaName;
          } catch (SQLException ex) {
              throw ex;
          } finally {
              close(rset);
          }
      }
docs: Find the next available schema name in the KAM catalog based on the
  {@link SystemConfiguration#getKamSchemaPrefix() KAM schema prefix}.
  
  @return the next available schema name
  @throws SQLException Thrown if the SQL query to the KAM catalog failed