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
| requete1 = "insert into mabase.patient (Nom_patient, Prenom_patient, SEXE, DateNaissance_patient, LieuNaissance_patient, Adresse_patient, Telephone, Antecedent_patient, AntecedentType_patient, Allergique_patient,NomActe_patient, MedecinCorres_patient, Assurence_patient, Mutuel_patient, Doit_patient, Recu_Patient, Reste_patient) values ('"+ strNom+ "','"+ strPrenom+ "','"+ strSexe+ "','"+ strDateNaissance+ "','"+ strLieuNaissance+ "','"+ strAdresse+ "','"+ strGSM+ "','"+ strAntecedent+ "','"+ strAntecedentType+ "','"+ strAllergique+ "','"+ strNomActe+ "','"+ strMedecin+ "','"+ strAssurence+ "','"+ strMutuel+ "','"+ strDoit+ "','"+ strRecue+ "','" + strReste + ")";
Connection conn = null;
ResultSet Resultats = null;
// chargement de pilote
try {
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e1) {
JOptionPane.showConfirmDialog(null, "impossible de charger le driver JdbcOdbcDriver",
" charge pilote" + e1,
JOptionPane.WARNING_MESSAGE);
}
// connexion à la base de donnée
try {
String DBurl = "jdbc:mysql://localhost/mabase";
conn = DriverManager.getConnection(DBurl, "root", "");
JOptionPane.showConfirmDialog(null, "driver marche bien",
"Connexion db ", JOptionPane.WARNING_MESSAGE);
} catch (SQLException e2) {
JOptionPane.showConfirmDialog(null,
"Impossible de de connecter à la base de donnée" + e2,
"Connexion db ", JOptionPane.WARNING_MESSAGE);
}
// Creation et execution de la requete;
try {
Statement stm = conn.createStatement();
Resultats = stm.executeQuery(requete1);
JOptionPane.showInternalConfirmDialog(null, "Confirmation.",
"Le produit " + strNom + " a etait bien ajouté",
JOptionPane.CANCEL_OPTION);
} catch (SQLException e3) {
JOptionPane.showConfirmDialog(null, " une anomalie conserant la requete sql"+ e3,
"requete sql" ,
JOptionPane.WARNING_MESSAGE); // voilà l'erreur c'est de cette ligne.
}
}
} |
Partager