title: How to check if an JPA/hibernate database is up with second-level caching
body: <p>I have a JSP/Spring application using Hibernate/JPA connected to a database. I have an external program that check if the web server is up every 5 minutes.</p>
  
  <p>The program call a specific URL to check if the web server is still running. The server returns "SUCCESS". Obviously if the server is now, nothing is returned. The request timesout and an alert is raised to inform the sysadmin that something is wrong...</p>
  
  <p>I would like to add another layer to this process: I would like the server to return "ERROR" if the database server is down. Is there a way using Hibernate to check if the database server is alive and well?</p>
  
  <p>What I tought to do was to take an object and try to save it. This would work, but I think it's probably too much for what I want. I could also read(load) an object from the database. But since we use second-level caching for all our objects, the object will be loaded from the cache, and not the database.</p>
  
  <p>What I'm looking for is something like:</p>
  
  <pre><code>HibernateUtils.checkDatabase()
  </code></pre>
  
  <p>Does such a function exist in Hibernate?</p>