Hi,
I am wondering how I can catch a possible exception using Hibernate JPA, when creating a new instance with EntityManagerFactory? I am working with Hibernate 3.3.1 and Entitymanager 3.4.0.
For example if the database is not reachable or so, I would like to catch the exception, however I have not succeeded to do so. Catching the Throwable does not work either.
Here is my code.
Code:
try {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("my_database", null);
} catch (Throwable t) {
// I want to go here if something goes wrong...
System.out.println("** Error: " + t.getMessage());
}
Any hints on how to do this?
Thanks!
Paul