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
|
public static void nouvel_employe (Connection poConn, BeanEmploye poEmploye)
throws SQLException {
/***********************************************************************************
* création de la requête permettant la creation d'un nouvel employé *
***********************************************************************************/
if (poEmploye.getMsNom()!=null) {
String lsReqSql = "INSERT INTO DTPointeuse values ('"+poEmploye.getMsNom()+"','"
+poEmploye.getMsPrenom()+ "')";
Statement loStatementSql = null;
try {
Class.forName("org.gjt.mm.mysql.Driver");
poConn = DriverManager.getConnection("jdbc:mysql://127.0.0.1/DTPointeuse","root","klavier");
// poConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/dtpointeuse","root","klavier");
loStatementSql = poConn.createStatement ();
loStatementSql.executeUpdate (lsReqSql);
} catch (Exception loEx){
System.out.println("erreur de merde: " + loEx);
} finally {
if (loStatementSql != null)
{
loStatementSql.close ();
}
}
} else {
poEmploye.setMsNom ("Mettre un nom");
}
}// fin nouvel_employe
} |
Partager