Exemplo n.º 1
0
  public static void anonymise(AppContext c, String table) throws DataFault {
    try {
      if (Repository.READ_ONLY_FEATURE.isEnabled(c)) {
        return;
      }
      SQLContext conn = c.getService(DatabaseService.class).getSQLContext();
      if (conn == null) {
        throw new DataFault("No connection");
      }

      StringBuilder sb = new StringBuilder();
      sb.append("UPDATE ");
      conn.quote(sb, table);
      sb.append(" SET ");
      conn.quote(sb, MESSAGE);
      sb.append("=null");

      Statement stmt = conn.getConnection().createStatement();
      int results = stmt.executeUpdate(sb.toString());
      stmt.close();
    } catch (SQLException e) {
      throw new DataFault("Error in delete", e);
    }
  }