示例#1
0
  public PreparedStatement prepareStatement(SqlDao dao, String query) throws SQLException {
    StringBuffer ret = new StringBuffer();
    Matcher m = TABLE_PATTERN.matcher(query);
    while (m.find()) {
      m.appendReplacement(ret, dao.getDataStore().getTableName(m.group(1), true));
    }
    m.appendTail(ret);

    return dao.prepareStatement(ret.toString());
  }
示例#2
0
  public String getOption(
      SqlDao dao, String name, LegacyMigration.Type type, String world, String option)
      throws SQLException {
    try (PreparedStatement stmt = dao.prepareStatement(getSelectOptionQuery())) {
      stmt.setString(1, name);
      stmt.setInt(2, type.ordinal());
      stmt.setString(3, option);
      if (world == null) {
        stmt.setNull(4, Types.VARCHAR);
      } else {
        stmt.setString(4, world);
      }

      ResultSet rs = stmt.executeQuery();
      if (rs.next()) {
        return rs.getString(1);
      } else {
        return null;
      }
    }
  }