code: static boolean isSafeReturnType(Class<?> type) { 
          return !ConnectionPoolDataSource.class.isAssignableFrom(type)
                 && !CommonDataSource.class.isAssignableFrom(type) 
                 && !XADataSource.class.isAssignableFrom(type)
                 && !DataSource.class.isAssignableFrom(type)
                 && !PooledConnection.class.isAssignableFrom(type) // implies XAConnection
                 && !Connection.class.isAssignableFrom(type)
                 && !DatabaseMetaData.class.isAssignableFrom(type)
                 && !Statement.class.isAssignableFrom(type) // implies prepared & callable
                 && !ResultSet.class.isAssignableFrom(type)
                 && !XAResource.class.isAssignableFrom(type);
      }
docs: Determine whether it is safe to return the result of an operation performed by the
  underlying implementation from a dynamic JDBC wrapper.
  
  @param type the Java type of a value returned by a method.
  
  @return TRUE if safe. FALSE if not safe.