Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ApplicationScoped
- public class EntityManagerProducer {
- private EntityManagerFactory factory;
- public EntityManagerProducer() throws FileNotFoundException, IOException {
- Properties p = new Properties();
- p.load(new FileInputStream("./conexao.properties"));
- factory = Persistence.createEntityManagerFactory("AlmoxarifadoPU");
- }
- @Produces @RequestScoped
- public EntityManager createEntityManager() {
- return factory.createEntityManager();
- }
- public void closeEntityManager(@Disposes EntityManager manager) {
- manager.close();
- }
- jdbc.user=root
- jdbc.password=
- jdbc.url=jdbc:mysql://localhost/almoxarifadome"
- jdbc.driver=com.mysql.jdbc.Driver
- InputStream is = null;
- Properties p = new Properties();
- is = EntityManagerProducer.class.getClassLoader().getResourceAsStream('conexao.properties');
- p.load(is);
Add Comment
Please, Sign In to add comment