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