Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. package DAO;
  2. import BD.*;
  3. import Bean.*;
  4. import java.sql.*;
  5.  
  6. public class DAOEmploye {
  7.  
  8. private SessionOracle s;
  9. private Statement stmt;
  10.  
  11. public DAOEmploye(SessionOracle ss) throws SQLException
  12. {
  13. this.s = ss;
  14. this.stmt = s.getConnection().createStatement();
  15. }
  16.  
  17. public void create(Employe e)
  18. {
  19. try {
  20. System.out.println("Création de l'employé dans la table ...");
  21. stmt.executeUpdate("INSERT INTO COPY_EMPLOYE VALUES(" + e.getNuempl() + ",'" + e.getNomempl() + "'," + e.getHebdo() + "," + e.getAffect() + "," + e.getSalaire() + ")");
  22. System.out.println("Insertion réussie !");
  23. } catch (SQLException e1) {
  24. System.out.println(e1);
  25. }
  26. }
  27. public void delete(Employe e)
  28. {
  29. try {
  30. System.out.println("Supression de la ligne de la table ...");
  31. stmt.executeUpdate("DELETE FROM COPY_EMPLOYE WHERE nuempl=" + e.getNuempl());
  32. System.out.println("Supression réussie !");
  33. } catch (SQLException e1) {
  34. System.out.println(e1);
  35. }
  36. }
  37.  
  38. public void update(Employe e)
  39. {
  40. try {
  41. System.out.println("Update de la ligne de la table ...");
  42. stmt.executeUpdate("UPDATE COPY_EMPLOYE SET nuempl=" + e.getNuempl());
  43. System.out.println("Update réussie !");
  44. } catch (SQLException e1) {
  45. System.out.println(e1);
  46. }
  47. }
  48.  
  49. public void read()
  50. {
  51. try {
  52. stmt.executeQuery("Select * from COPY_EMPLOYE order by 1");
  53. }
  54. catch (SQLException e) {
  55. System.out.println(e.getMessage());
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement