Guest User

Untitled

a guest
Feb 11th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. @ApplicationScoped
  2. public class EntityManagerProducer {
  3.  
  4. private EntityManagerFactory factory;
  5.  
  6. public EntityManagerProducer() throws FileNotFoundException, IOException {
  7. Properties p = new Properties();
  8.  
  9. p.load(new FileInputStream("./conexao.properties"));
  10.  
  11.  
  12. factory = Persistence.createEntityManagerFactory("AlmoxarifadoPU");
  13. }
  14.  
  15. @Produces @RequestScoped
  16. public EntityManager createEntityManager() {
  17. return factory.createEntityManager();
  18. }
  19.  
  20. public void closeEntityManager(@Disposes EntityManager manager) {
  21. manager.close();
  22. }
  23.  
  24. jdbc.user=root
  25. jdbc.password=
  26. jdbc.url=jdbc:mysql://localhost/almoxarifadome"
  27. jdbc.driver=com.mysql.jdbc.Driver
  28.  
  29. InputStream is = null;
  30. Properties p = new Properties();
  31.  
  32. is = EntityManagerProducer.class.getClassLoader().getResourceAsStream('conexao.properties');
  33. p.load(is);
Add Comment
Please, Sign In to add comment