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
| public void AjoutPersonne() {
PersonneBean pers = new PersonneBean();
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost/osteo";
String login = "root";
String password = "mysql";
String requete = "";
try {
Class.forName(driver);
con = DriverManager.getConnection(url,login,password);
stmt = con.createStatement();
requete = "INSERT INTO personne(id,nom,prenom,naissance,adresse,profession,mobile,telephone,email,dateConsult) VALUE('6',amo','fri','','','','','','','','','','','','','')";
int nbMaj = stmt.executeUpdate(requete);
System.out.println("nb mise a jour = "+nbMaj);
}
catch(ClassNotFoundException cnfe){
System.out.println("Driver introuvable : ");
cnfe.printStackTrace();
}
catch(SQLException sqle){
System.out.println("Erreur SQL : La BD n'est pas démarré");
}
catch(Exception e){
System.out.println("Autre erreur : ");
e.printStackTrace();
}
} |
Partager