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.
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.
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.