1 Reply Latest reply on Apr 1, 2015 5:51 PM by Max Ozkin

    SQL binding raised exceptions

    Max Ozkin Apprentice

      I have a composite reference with SQL binding. Is there a way to specify the exception(s) that could be raised by my method (in Java reference interface) in case of SQL/DB issues?


      As of now Java method has no exceptions declared. And if there is some run-time problem, like connectivity issue with the database server or wrong SQL statement, then this method just throws RuntimeException "java.lang.reflect.UndeclaredThrowableException"..


      Is there any way to better control exception handling for SQL binding or my only solution is to add try/catch for that particular RuntimeException and then analyze its cause?

        • 1. Re: SQL binding raised exceptions
          Max Ozkin Apprentice

          An observation. If you add "throws Exception" declaration to your method in Java reference interface, then instead of getting boring java.lang.reflect.UndeclaredThrowableException you can catch more meaningful exception (by catching Exception or RuntimeException) like below:


          org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/datasources/test