private BaseDAO connDAO;
private Contratos contratos;
/**
* Cadastra o contrato do consorciado importado.
* @param contratos
* @throws Exception
*/
public void cadastrarContrato () throws Exception {
PreparedStatement stmt = null;
Connection connection = null;
ResultSet resultSet = null;
try {
connDAO = new BaseDAO();
connection = connDAO.getConnection();
StringBuffer SQL = new StringBuffer();
// INSERT
SQL.append(" INSERT INTO ").append("CONTRAT0").append("( ");
SQL.append(" CONTRATO_ID, ");
SQL.append(" CONTRATO, ");
SQL.append(" COBRADOR, ");
SQL.append(" DT_ENT, ");
SQL.append(" NOME, ");
SQL.append(" ANDAMENTO, ");
SQL.append(" DT_ANDA, ");
SQL.append(" STS1, ");
SQL.append(" DT_STS1,");
SQL.append(" STS2, ");
SQL.append(" DT_STS2, ");
SQL.append(" DPTO, ");
SQL.append(" PLD,");
SQL.append(" CONTRATO_F,");
SQL.append(" OBITO, ");
SQL.append(" DT_ENVN, ");
SQL.append(" DT_RECN, ");
SQL.append(" DT_PDOC, ");
SQL.append(" DT_RDOC, ");
SQL.append(" DT_ENCAR, ");
SQL.append(" DT_RECAR, ");
SQL.append(" INFPLD, ");
SQL.append(" ATIVO, ");
SQL.append(" PRODUTO_ID, ");
SQL.append(" NUMIDENT_ID ");
// VALUES
SQL.append(") VALUES ( ");
SQL.append(" ?, "); // 1 - 'Parâmetro de ID do Contrato_ID',
SQL.append(" ?, "); // 2 - 'Parâmetro de Contrato',
SQL.append(" ?, "); // 3 - 'Parâmetro de Cobrador',
SQL.append(" ?, "); // 4 - 'Parâmetro de DT_Entrada',
SQL.append(" ?, "); // 5 - 'Parâmetro de Nome',
SQL.append(" ?, "); // 6 - 'Parâmetro de Andamento',
SQL.append(" ?, "); // 7 - 'Parâmetro de DT_Anda',
SQL.append(" ?, "); // 8 - 'Parâmetro de Sts1',
SQL.append(" ?, "); // 9 - 'Parâmetro de DT_Sts1',
SQL.append(" ?, "); // 10 - 'Parâmetro de Sts2',
SQL.append(" ?, "); // 11 - 'Parâmetro de DT_Sts2',
SQL.append(" ?, "); // 12 - 'Parâmetro de Dpto',
SQL.append(" ?, "); // 13 - 'Parâmetro de Pld',
SQL.append(" ?, "); // 14 - 'Parâmetro de Contrato_F',
SQL.append(" ?, "); // 15 - 'Parâmetro de Obito',
SQL.append(" ?, "); // 16 - 'Parâmetro de DT_Envn',
SQL.append(" ?, "); // 17 - 'Parâmetro de DT_Recn',
SQL.append(" ?, "); // 18 - 'Parâmetro de DT_Pdoc',
SQL.append(" ?, "); // 19 - 'Parâmetro de DT_Rdoc',
SQL.append(" ?, "); // 20 - 'Parâmetro de DT_Envar',
SQL.append(" ?, "); // 21 - 'Parâmetro de DT_Recar',
SQL.append(" ?, "); // 22 - 'Parâmetro de Infpld',
SQL.append(" ?, "); // 23 - 'Parâmetro de Ativo',
SQL.append(" ?, "); // 24 - 'Parâmetro de Produto_ID',
SQL.append(" ? "); // 25 - 'Parâmetro de Numident_ID'
SQL.append(" ) ");
// VALORES REAIS
stmt.setInt (1, contratos.getContratoID());
stmt.setString (2, contratos.getContrato());
stmt.setString (3, contratos.getCobrador());
stmt.setString (4, contratos.getDtEntrada());
stmt.setString (5, contratos.getNome());
stmt.setString (6, contratos.getAndamento());
stmt.setString (7, contratos.getDtAndam());
stmt.setInt (8, contratos.getSts1());
stmt.setString (9, contratos.getDtSts1());
stmt.setInt (10, contratos.getSts2());
stmt.setString (11, contratos.getDtSts2());
stmt.setInt (12, contratos.getDpto());
stmt.setString (13, contratos.getPLD());
stmt.setString (14, contratos.getContratoF());
stmt.setString (15, contratos.getObito());
stmt.setString (16, contratos.getDtEnvn());
stmt.setString (17, contratos.getDtRecn());
stmt.setString (18, contratos.getDtPdoc());
stmt.setString (19, contratos.getDtRdoc());
stmt.setString (20, contratos.getDtEnvar());
stmt.setString (21, contratos.getDtRecar());
stmt.setString (22, contratos.getInfPld());
stmt.setString (23, contratos.getAtivo());
stmt.setInt (24, contratos.getProdutoID());
stmt.setInt(25, contratos.getNumidentID());
stmt = connection.prepareStatement( SQL.toString() );
resultSet = stmt.executeQuery();
stmt.close();
connDAO.closeConnection(stmt, resultSet);
resultSet.close();
stmt = null;
SQL = null;
} catch (Exception e) {
e.printStackTrace();
throw new Exception("DAO-051: ERRO AO CADASTRAR CONTRATO.");
}
}