Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. private static EntityManagerFactory getEntityManagerFactory() {
  2. if (entityManagerFactory == null) {
  3. InputStream propertiesStream = null;
  4. try {
  5. propertiesStream = new FileInputStream(ContextParams.getDbPropertiesFile());
  6. final Properties properties = new Properties();
  7. properties.load(propertiesStream);
  8. entityManagerFactory = Persistence.createEntityManagerFactory("JURE_PU", properties);
  9. } catch (Exception exception) {
  10. LOGGER.error("Could not load DB properties. " + exception);
  11. throw new ExceptionInInitializerError(exception);
  12. } finally {
  13. try {
  14. if (propertiesStream != null) {
  15. propertiesStream.close();
  16. }
  17. } catch (IOException exception) {
  18. LOGGER.error("Could not close DB properties stream. " + exception);
  19. }
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement