Exemple #1
0
  public void true_insert() throws Exception {
    // synchronized(variavel) {

    Database db = new Database();
    db.connect();
    // BEGIN WORK -> stored procedure
    db.update(
        "insert into tbNews (tmsp, headline, body, email) values ('"
            + this.tmsp
            + "', '"
            + this.headline
            + "', '"
            + this.body
            + "', '"
            + this.email
            + "')");
    ResultSet rs = db.query("select max(id) as id from tbNews");
    if (rs.next()) {
      this.id = rs.getInt("id");
    }
    // COMMIT

    db.close();

    // }
  }
Exemple #2
0
  public static News next(ResultSet rs) throws Exception {
    News news = null;

    if (rs.next()) {
      news =
          new News(
              rs.getInt("id"),
              rs.getString("tmsp"),
              rs.getString("headline"),
              rs.getString("body"),
              rs.getString("email"));
    }

    return news;
  }