-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: [Hibernate EntityManager] - createEntityManageractory
PostPosted: Thu Feb 21, 2008 2:07 pm 
Newbie

Joined: Mon Oct 29, 2007 11:50 am
Posts: 5
Hibernate version: 3.2.5
Hibernate EntityManager version: 3.3.1.GA


Hi.
I have this class that create EntityManagers:

Code:
imports ...
public class JPAHelper {

   static Logger logger = Logger.getLogger(JPAHelper.class);
   
   private static EntityManagerFactory emf;

   public static EntityManager createEntityManager() throws InitializationException {
      if (emf == null) {
         String persistenceUnitName;
         try {
            persistenceUnitName = Util.getProperty("tpcc.ufpr.persistence.unit.name");
            emf = Persistence.createEntityManagerFactory(persistenceUnitName);
         } catch (Exception e) {
            logger.error(e.getLocalizedMessage());
            throw new InitializationException(e.getLocalizedMessage());
         }
      }
      return emf.createEntityManager();
   }
}


For test reasons I'm runnig this part of code with the DBMS turned off. As obvius, when program executes this line:
Code:
Persistence.createEntityManagerFactory(persistenceUnitName);


an exception is plotted in console view as follows:

Code:
15:54:40,444  INFO SchemaUpdate:94 - fetching database metadata
15:54:41,382 ERROR SchemaUpdate:119 - could not get database metadata
org.postgresql.util.PSQLException: Conexão negada. Verifique se o nome da máquina e a porta estão corretos e se o postmaster está aceitando conexões TCP/IP.
   at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:122)
   at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
   at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125)


Despite this exception, the block inside [i]catch[/] isnt executed.

How do I catch this exception?

Thanks in advance.

Murilo


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.