-
1. Re: How to detect lost database connection using injected EntityManager?
wdfink Sep 14, 2011 4:07 AM (in response to profinator)what you want to achieve?
If you use injection it is the responsibility of the container to connections.
You can not control the SQL behind (e.g. a long running query). There is no thread control whether it takes too long, also in most cases the query can not be interrupted.
In most cases the DB connection should work and you should think about the environment if the connection is lost lot of times.
Also you might reconsider the use case if the queries takes long time.
-
2. Re: How to detect lost database connection using injected EntityManager?
profinator Sep 14, 2011 7:54 PM (in response to wdfink)Hi,
What I'd like is to find it out if there is a quick way to test whether or not the remote database is accessible using an injected EntityManager, without having to wait for the EntityManager to start throwing exceptions.
From your resonse it sounds like there isn't an easy way to do it using injected EntityManager because all of the connection work is performed in the container. So maybe the solution is that we shouldn't be using an injected EntityManager, the other option is to manually establish the connection and check whether or not it is still active.
Thanks for the response.
-
3. Re: How to detect lost database connection using injected EntityManager?
wdfink Sep 15, 2011 2:26 AM (in response to profinator)EntityManager uses the containers connection pool.
Here you are able to configure how a DB connection should be checked, e.g. if puplished or periodicaly.
See http://community.jboss.org/wiki/configdatasources for this.