Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Handle Connection Exception

Habib EslamiJun 27 2022 — edited Jun 27 2022

Hi dears,
I use jdev 11.1.1.7.0.
I need to handle the closed connection exception in my project, for this I've created MyErrorHandler class which extends DCErrorHandlerImpl (also updated DataBindings.cpx) and I've override the reportException() method as below :

    @Override
    public void reportException(DCBindingContainer formBnd, Exception ex) {
        String msg = "";
        JboException e = null;
        Object[] exceptions;     

        if (ex instanceof java.sql.SQLRecoverableException) {
            msg = ex.getMessage();
            if (msg.indexOf("Connection") >= 0) {
                e = new JboException("errro in connection to database ...");
                throw new JboException(e);
            } else {
                super.reportException(formBnd, ex);
            }

        } else if (ex instanceof javax.el.ELException) {
            msg = ex.getMessage();
            if (msg.indexOf("JBO-26061") >= 0) {                
                e = new JboException("errro in connection to database ...");
                throw new JboException(e);

            } else {
                super.reportException(formBnd, ex);
            }

        } else if (ex instanceof oracle.jbo.DMLException) {          
            this.reportException(formBnd, (Exception)ex.getCause());

        } else if (ex instanceof oracle.jbo.JboException) {
            exceptions = ((JboException)ex).getDetails();  
          
            if (exceptions.length > 0) {         
                for (int i = 0; i < exceptions.length; i++) {
                    this.reportException(formBnd, (Exception)exceptions[i]);
                }
            } else {               
                super.reportException(formBnd, ex);               
            }
        }
    }

when the connection is closed(in any reasons) the pop up error shows to user, which is too unclear
popup error.png
Is there any solution to handle this exception and then navigate to Error page or Login page.
Regards,
Habib

Comments
Post Details
Added on Jun 27 2022
25 comments
684 views