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 44 45 46 47 48 49 50 51 52
| -------------------------------------------------------------------------
public class VehiculeFactory {
/** Creates a new instance of VehiculeFactory */
public VehiculeFactory() {
}
static Vehicule creerVehicule(String marque, String model, String prix, String couleur) throws IllegalArgumentException
{
Vehicule temp= new Vehicule(marque,model,prix,couleur);
String marequete = "insert into VEHICULE values ('"+temp.getMarque()+"','"+temp.getModel()+"','"+prix+"','"+temp.getCouleur()+"')";
try{
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection conn =
DriverManager.getConnection("jdbc:derby://localhost:1527/Application", "nfe114",
"nfe114");
Statement st = conn.createStatement();
boolean result = st.execute(marequete);
conn.close();
}
catch(IllegalArgumentException i){
System.err.println("Erreur ajout vehicule : " + i);
}
catch(SQLException sql){
System.out.println("Erreur SQLajout vehicule ici");
System.err.println(sql.getMessage());
}
catch(ClassNotFoundException c){
System.err.println("Erreur ClassNotFoundException ajout vehicule : " + c);
}
return temp;
}
static Vehicule[] RechercherVehicul(String marque){
String marequet = "select * from VEHICULE where marque ="+marque+"";
Vehicule [] retour = new Vehicule[10];
String marqu, model, couleur;
String prix;
boolean result =false;
ResultSet rs;
ConnexionBase base = new ConnexionBase(marequet);
for(int i=0;i<base.resultat.length;i++){
for(int j=0;j<base.nombre_col;j++){
System.out.print(base.resultat[i][j]);
}
System.out.println();
}
return retour;
}
}
------------------------------------------------------------------------- |
Partager