Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dao;
- import java.sql.CallableStatement;
- //import java.sql.Connection;
- import java.sql.SQLException;
- import bd.SessionOracle;
- import bean.*;
- public class DAOEmployeter {
- // private Connection connection;
- private SessionOracle s;
- public DAOEmployeter(SessionOracle ss) {
- this.s = ss;
- }
- public void create(Employe e) {
- System.out.println("Insertion de la ligne dans la table ...");
- try {
- CallableStatement callstmt = s.getConnection().prepareCall("Call MAJ.creer_un_employe(?,?,?,?,?)");
- callstmt.setInt(1, e.getNuempl());
- callstmt.setString(2, e.getEmploye());
- callstmt.setInt(3, e.getHebdo());
- callstmt.setInt(4, e.getAffect());
- callstmt.setInt(5, e.getSalaire());
- callstmt.execute();
- System.out.println("Insertion réussie !");
- } catch (SQLException e1) {
- System.out.println("Erreur : L'insertion a échoué");
- e1.printStackTrace();
- }
- }
- public void delete(Employe e) {
- System.out.println("Supression de la ligne de la table ...");
- try {
- CallableStatement callstmt = s.getConnection().prepareCall("DELETE FROM EMPLOYE2 WHERE nuempl= ?");
- callstmt.setInt(1, e.getNuempl());
- System.out.println("Supression réussie !");
- } catch (SQLException e1) {
- System.out.println("Erreur : La suppression a échoué");
- e1.printStackTrace();
- }
- }
- public void update(Employe e) {
- try {
- System.out.println("Mise à jour de l'employé ...");
- CallableStatement callstmt = s.getConnection().prepareCall(
- "UPDATE EMPLOYE2 SET nomempl=?, hebdo=?, affect=?, nomempl=?, salaire=? Where nuempl=?");
- callstmt.setString(1, e.getEmploye());
- callstmt.setInt(2, e.getHebdo());
- callstmt.setInt(3, e.getAffect());
- callstmt.setString(4, e.getEmploye());
- callstmt.setInt(5, e.getSalaire());
- callstmt.setInt(6, e.getNuempl());
- System.out.println("Mise à jour réussie !");
- } catch (SQLException e1) {
- System.out.println("Erreur : La mise à jour a échoué");
- e1.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement