How to detect Oracle database shutdown in JDBC?
<p>In an application, we have used JDBC to connect to Oracle database. We have attached. The issue is to identify through a callback/listener, that the database was shutdown. </p>

<p>Currently, we have the the following listener attached:</p>

<pre><code>Connection eventListener = new ConnectionEventListener() {
    @Override
    public void connectionErrorOccurred(ConnectionEvent event){
        // log - connection error
    }

    @Override
    public void connectionClosed(ConnectionEvent event) {
        // log - connection closed
    }
}
</code></pre>

<p>None of this events are triggered when the database is shutdown.</p>

<p>The idea is to <strong>detect the database shutdown</strong> and then <strong>the database start</strong>, and have a mechanism to inform the users, and to either poll for the database (configurable) or suspend the service (the application).</p>