1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
public Contrat findById(int id) throws SQLException {
String query = "SELECT * FROM contrat WHERE idcontrat = " + id + ";";
ResultSet rs = null;
Contrat c = null;
try {
statement = connection.createStatement();
rs = statement.executeQuery(query);
while(rs.next()){
TypeContrat tc = new TypeContratDAO().findById(rs.getInt("idtypecontrat"));
Employe emp = new EmployeDAO().findById(rs.getString("idemp"));
Phase ph = new PhaseDAO().findById(rs.getInt("idphase"));
Poste po = new PosteDAO().findById(rs.getInt("idposte"));
FiliereContrat fc = new FiliereContratDAO().findById(rs.getInt("idfiliere"));
CategorieContrat categ = new CategorieContratDAO().findById(rs.getInt("idcategorie"));
StatutContrat sta = new StatutContratDAO().findById(rs.getInt("idstatut"));
Salaire sa = new SalaireDAO().findById(rs.getInt("idsalaire"));
Signataire si = new SignataireDAO().findById(rs.getInt("idsignataire"));
EtapeContrat ec = new EtapeContratDAO().findById(rs.getInt("idetape"));
Filiale fil = new FilialeDAO().findById(rs.getInt("idfiliale"));
EtatContrat et = new EtatContratDAO().findById(rs.getInt("idetat"));
Avenant av = new AvenantDAO().findById(rs.getInt("idavenant"));
c = new Contrat(rs.getInt("idcontrat"),tc,emp,ph,po,fc,categ,sta,sa,si,ec,fil,et,av);
}
}
catch (SQLException e) {
System.out.println("Erreur SQL :" + e);
}
finally {
DbUtil.close(rs);
DbUtil.close(statement);
DbUtil.close(connection);
}
return c;
} |
Partager