Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package esame;
  7.  
  8. import javax.annotation.PostConstruct;
  9. import javax.annotation.PreDestroy;
  10. import javax.annotation.sql.DataSourceDefinition;
  11. import javax.ejb.Singleton;
  12. import javax.ejb.Startup;
  13. import javax.inject.Inject;
  14.  
  15. /**
  16. *
  17. * @author Desi
  18. */
  19. @Singleton
  20. @Startup
  21. @DataSourceDefinition(
  22. user = "app",
  23. password = "app",
  24. databaseName = "ËsameDB",
  25. className = "org.apache.derby.jdbc.EmbeddedDataSource",
  26. name = "java:global/jdbc/EsameDS",
  27. properties = {"connectionAttributes=;create=true"}
  28. )
  29. public class DatabasePopulator {
  30. @Inject
  31. private TaskEJB taskEJB;
  32. private Task t1,t2,t3;
  33. @PostConstruct
  34. public void CreateDB(){
  35. t1 = new Task("Completare pagina home del Sito web","comunicazione","Maria",4,0);
  36. t2 = new Task("Presentazione novità","innovazione","nessuno",2,75);
  37. t3 = new Task("Emettere fattura cliente 2","amministrazione","Pasquale",7,100);
  38.  
  39. taskEJB.createTask(t1);
  40. taskEJB.createTask(t2);
  41. taskEJB.createTask(t3);
  42.  
  43. }
  44.  
  45. @PreDestroy
  46. public void clearDB(){
  47. taskEJB.deleteTask(t1);
  48. taskEJB.deleteTask(t2);
  49. taskEJB.deleteTask(t3);
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement