code: public static SQLException toSQLException(Throwable ex) {
          if (ex == null)
              return null; 
  
          if (ex instanceof SQLException)
              return (SQLException) ex;
  
          if (ex instanceof ResourceException)
              return toSQLException((ResourceException) ex);
  
          // Link the original exception to the new SQLException. 
  
          SQLException sqlX = new SQLException(ex.getClass().getName() + ": " + ex.getMessage());
          sqlX.initCause(ex);
  
          return sqlX;
      }
docs: Converts any generic Exception to a SQLException.
  
  @param ex the exception to convert.
  
  @return SQLException containing the original Exception class, message, and stack trace.