Ejemplo n.º 1
0
 //	public static void update(Commande obj) {
 //		Connection dbConnection = null ;
 //		PreparedStatement preparedStatement = null;
 //		try{
 //			dbConnection = DaoCon.getCon();
 //			preparedStatement = dbConnection.prepareStatement(updateQuery);
 //			preparedStatement.setInt(1, obj.getClient().getId());
 //			preparedStatement.setString(2, obj.getAdresse());
 //			preparedStatement.setDate(3, new java.sql.Date(obj.getDate().getTime()));
 //			preparedStatement.setString(4, obj.getEtat().toString());
 //			preparedStatement.setInt(5, obj.getId());
 //			preparedStatement.executeUpdate();
 //		}catch (Exception e){
 //			e.printStackTrace();
 //		}finally{
 //			DaoCon.close(dbConnection, preparedStatement);
 //		}
 //	}
 public static void update(Commande obj) {
   Connection dbConnection = null;
   PreparedStatement preparedStatement = null;
   try {
     dbConnection = DaoCon.getCon();
     preparedStatement = dbConnection.prepareStatement(updateQuery);
     preparedStatement.setString(1, obj.getEtat().toString());
     preparedStatement.setInt(2, obj.getId());
     preparedStatement.executeUpdate();
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     DaoCon.close(dbConnection, preparedStatement);
   }
 }
Ejemplo n.º 2
0
 private static Commande mapRes(ResultSet rs, boolean withList) {
   if (!withList) {
     return mapRes(rs);
   } else {
     Commande commande = new Commande();
     try {
       commande.setId(rs.getInt("IDCOMMANDE"));
       commande.setClient(DaoClient.find(rs.getInt("IDCLIENT")));
       commande.setAdresse(rs.getString("ADRESSECOMMANDE"));
       commande.setDate(rs.getTimestamp("TIMECOMMANDE"));
       commande.setEtat(Commande.stringToEnum(rs.getString("ETATCOMMANDE")));
       commande.setPlacoms(DaoPlaCom.findByCommande(commande.getId()));
     } catch (Exception e) {
       e.printStackTrace();
     }
     return commande;
   }
 }