public Database getDatabase(String catName, String dbName) throws MetaException{
    String queryTextDbSelector= "select "
        + "\"DB_ID\", \"NAME\", \"DB_LOCATION_URI\", \"DESC\", "
        + "\"OWNER_NAME\", \"OWNER_TYPE\", \"CTLG_NAME\" , \"CREATE_TIME\", \"DB_MANAGED_LOCATION_URI\", "
        + "\"TYPE\", \"DATACONNECTOR_NAME\", \"REMOTE_DBNAME\" "
        + "FROM "+ DBS
        + " where \"NAME\" = ? and \"CTLG_NAME\" = ? ";
    String queryTextDbParams = "select \"PARAM_KEY\", \"PARAM_VALUE\" "
        + " from " + DATABASE_PARAMS + " "
        + " WHERE \"DB_ID\" = ? "
        + " AND \"PARAM_KEY\" IS NOT NULL";

    try (QueryWrapper queryDbSelector = new QueryWrapper(pm.newQuery("javax.jdo.query.SQL", queryTextDbSelector));
         QueryWrapper queryDbParams = new QueryWrapper(pm.newQuery("javax.jdo.query.SQL", queryTextDbParams))) {
      dbName = dbName.toLowerCase();
      catName = catName.toLowerCase();
      Object[] params = new Object[] { dbName, catName };

      if (LOG.isTraceEnabled()) {
        LOG.trace("getDatabase:query instantiated : " + queryTextDbSelector
            + " with param [" + params[0] + "]");
      }

      List<Object[]> sqlResult = executeWithArray(
          queryDbSelector.getInnerQuery(), params, queryTextDbSelector);
      if ((sqlResult == null) || sqlResult.isEmpty()) {
        return null;
      }

      assert(sqlResult.size() == 1);
      if (sqlResult.get(0) == null) {
        return null;
      }

      Object[] dbline = sqlResult.get(0);
      Long dbid = MetastoreDirectSqlUtils.extractSqlLong(dbline[0]);

      params[0] = dbid;
      if (LOG.isTraceEnabled()) {
        LOG.trace("getDatabase:query2 instantiated : " + queryTextDbParams
            + " with param [" + params[0] + "]");
      }

      Map<String,String> dbParams = new HashMap<String,String>();
      List<Object[]> sqlResult2 = MetastoreDirectSqlUtils.ensureList(executeWithArray(
          queryDbParams.getInnerQuery(), params, queryTextDbParams));
      if (!sqlResult2.isEmpty()) {
        for (Object[] line : sqlResult2) {
          dbParams.put(MetastoreDirectSqlUtils.extractSqlString(line[0]), MetastoreDirectSqlUtils
              .extractSqlString(line[1]));
        }
      }
      Database db = new Database();
      db.setName(MetastoreDirectSqlUtils.extractSqlString(dbline[1]));
      db.setLocationUri(MetastoreDirectSqlUtils.extractSqlString(dbline[2]));
      db.setDescription(MetastoreDirectSqlUtils.extractSqlString(dbline[3]));
      db.setOwnerName(MetastoreDirectSqlUtils.extractSqlString(dbline[4]));
      String type = MetastoreDirectSqlUtils.extractSqlString(dbline[5]);
      db.setOwnerType(
          (null == type || type.trim().isEmpty()) ? null : PrincipalType.valueOf(type));
      db.setCatalogName(MetastoreDirectSqlUtils.extractSqlString(dbline[6]));
      if (dbline[7] != null) {
        db.setCreateTime(MetastoreDirectSqlUtils.extractSqlInt(dbline[7]));
      }
      db.setManagedLocationUri(MetastoreDirectSqlUtils.extractSqlString(dbline[8]));
      String dbType = MetastoreDirectSqlUtils.extractSqlString(dbline[9]);
      if (dbType != null && dbType.equalsIgnoreCase(DatabaseType.REMOTE.name())) {
        db.setType(DatabaseType.REMOTE);
        db.setConnector_name(MetastoreDirectSqlUtils.extractSqlString(dbline[10]));
        db.setRemote_dbname(MetastoreDirectSqlUtils.extractSqlString(dbline[11]));
      } else {
        db.setType(DatabaseType.NATIVE);
      }
      db.setParameters(MetaStoreServerUtils.trimMapNulls(dbParams,convertMapNullsToEmptyStrings));
      if (LOG.isDebugEnabled()){
        LOG.debug("getDatabase: directsql returning db " + db.getName()
            + " locn["+db.getLocationUri()  +"] desc [" +db.getDescription()
            + "] owner [" + db.getOwnerName() + "] ownertype ["+ db.getOwnerType() +"]");
      }
      return db;
    }
  }
This method returns a comma separated string consisting of String values of a given list.
This is used for preparing "SOMETHING_ID in (...)" to use in SQL queries.
@param objectIds the objectId collection
@return The concatenated list
@throws MetaException If the list contains wrong data
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java