コード例 #1
0
  /**
   * Updates a particular entry with a new value
   *
   * @param conn the database connection (to be used inside a try-catch(-finally)
   * @param id the id of the table/owner
   * @param key the key of the entry to update
   * @param value the new value of the specified key
   * @return whether or not it succeeded
   * @throws SQLException
   */
  @Override
  public boolean update(Connection conn, String id, String key, TradeForm value)
      throws SQLException {

    int i = 0;
    String statement =
        "UPDATE `tradeform:" + id + "` SET " + Query.DATA.v + "=? WHERE " + Query.NAME.v + "=?";

    PreparedStatement preparedStatement = conn.prepareStatement(statement);
    preparedStatement.setObject(++i, value.serialize());
    preparedStatement.setString(++i, key);

    return preparedStatement.execute();
  }
コード例 #2
0
  /**
   * Inserts a new entry
   *
   * @param conn the database connection (to be used inside a try-catch(-finally)
   * @param id the id of the table/owner
   * @param key the key of the entry to insert into
   * @param value the value of the entry to insert
   * @return whether or not it succeeded
   * @throws SQLException
   */
  @Override
  public boolean insert(Connection conn, String id, String key, TradeForm value)
      throws SQLException {

    int i = 0;
    String statement =
        "INSERT INTO `tradeform:"
            + id
            + "`("
            + Query.NAME.v
            + ", "
            + Query.DATA.v
            + ") values (?, ?)";

    PreparedStatement preparedStatement = conn.prepareStatement(statement);
    preparedStatement.setString(++i, key);
    preparedStatement.setObject(++i, value.serialize());

    return preparedStatement.execute();
  }