code: public static String queryString(Connection con, String def, String query, Object... param) throws SQLException {
      PreparedStatement stmt = null;
      try {
        stmt = con.prepareStatement(query);
        stmt.setMaxRows(1);
        for (int i = 0; i < param.length; i++) {
          stmt.setObject(i + 1, param[i]);
        }
        return queryString(stmt, def);
      } finally {
        close(stmt);
      }
    }
docs: Runs a SQL query that returns a single <code>String</code> value.
  @param con The <code>Connection</code> against which to run the query.
  @param def The default value to return if the query returns no results.
  @param query The SQL query to run.
  @param param The parameters to the SQL query.
  @return The value returned by the query, or <code>def</code> if the
  query returns no results.  It is assumed that the query
  returns a result set consisting of a single row and column, and
  that this value is a <code>String</code>.  Any additional rows or
  columns returned will be ignored.
  @throws SQLException If an error occurs while attempting to communicate
  with the database.