コード例 #1
0
ファイル: CongregacaoDao.java プロジェクト: vivianoads/IMCarm
  public void GravaCongregacao(CongregacaoBean congregacao)
      throws ClassNotFoundException, SQLException {

    Connection con = conexao.getConnection();

    String sqlInsercao =
        "INSERT INTO Congregacao (Nome, Carisma, Lema, Data_fundacao, Data_agregacao_ordem, Data_erecao_canonica, Cidade_fundacao, Fundador, Co_fundador) values (?, ?, ?, ?, ?, ?, ?, ?, ?)";

    PreparedStatement ps = con.prepareStatement(sqlInsercao);

    ps.setString(1, congregacao.getNome());
    ps.setString(2, congregacao.getCarisma());
    ps.setString(3, congregacao.getLema());
    ps.setString(4, congregacao.getDataFundacao());
    ps.setString(5, congregacao.getDataAgregacaoOrdem());
    ps.setString(6, congregacao.getDataErecaoCanonica());
    ps.setString(7, congregacao.getCidadeFundacao());
    ps.setString(8, congregacao.getFundador());
    ps.setString(9, congregacao.getCoFundador());

    if (this.getCountCongregacao() == 0) {
      ps.execute();
    } else {
      throw new SQLException("Congregação Já está cadastrada");
    }
    ps.close();
    con.close();
  }
コード例 #2
0
ファイル: CongregacaoDao.java プロジェクト: vivianoads/IMCarm
  public void alteraCongregacao(int idCongregacao, CongregacaoBean congregacaoBean)
      throws ClassNotFoundException, SQLException {
    Connection con = conexao.getConnection();
    String sql =
        "UPDATE congregacao SET nome = ?, carisma = ?, lema = ?, data_fundacao = ?, data_agregacao_ordem = ?, data_erecao_canonica = ?, cidade_fundacao = ?, fundador = ?, co_fundador = ? WHERE id_congregacao = ?";
    PreparedStatement ps = con.prepareStatement(sql);
    ps.setString(1, congregacaoBean.getNome());
    ps.setString(2, congregacaoBean.getCarisma());
    ps.setString(3, congregacaoBean.getLema());
    ps.setString(4, congregacaoBean.getDataFundacao());
    ps.setString(5, congregacaoBean.getDataAgregacaoOrdem());
    ps.setString(6, congregacaoBean.getDataErecaoCanonica());
    ps.setString(7, congregacaoBean.getCidadeFundacao());
    ps.setString(8, congregacaoBean.getFundador());
    ps.setString(9, congregacaoBean.getCoFundador());
    ps.setInt(10, idCongregacao);

    ps.executeUpdate();
    ps.close();
    con.close();
  }