Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. package DAO;
  2. import BD.*;
  3. import Bean.*;
  4. import java.sql.*;
  5.  
  6. public class DAOEmployeBis {
  7.  
  8. private SessionOracle s;
  9. private PreparedStatement pstmt;
  10.  
  11. public DAOEmployeBis(SessionOracle ss) throws SQLException
  12. {
  13. this.s = ss;
  14. this.pstmt = s.getConnection().prepareStatement();
  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. public void update(Employe e)
  38. {
  39. try {
  40. System.out.println("Update de la ligne de la table ...");
  41. stmt.executeUpdate("UPDATE COPY_EMPLOYE SET nuempl=" + e.getNuempl());
  42. System.out.println("Update réussie !");
  43. } catch (SQLException e1) {
  44. System.out.println(e1);
  45. }
  46. }
  47.  
  48. public void read()
  49. {
  50. try {
  51. stmt.executeQuery("Select * from COPY_EMPLOYE order by 1");
  52. }
  53. catch (SQLException e) {
  54. System.out.println(e.getMessage());
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement