2016-07-18 11 views
0

私のメソッドにSQLGrammarExceptionを実装しようとしています。 このメソッドは、私に列のエラーを表示しますが、私はどのプロシージャにエラーがある列を表示する必要があります。メソッドにSQLGrammarExceptionを実装しようとします。

public static PersistenceMicrodataException dealHibernateException(Throwable e) { 
    e.printStackTrace(); 
    Throwable t = ExceptionUtil.getCause(e); 
    return new PersistenceMicrodataException(t.getMessage(), t); 
} 

私はこれを試してみてください。

public static PersistenceMicrodataException dealHibernateException(Throwable e) { 
    try { 
     Throwable t = ExceptionUtil.getCause(e); 
    } catch (Exception e) { 
     System.out.println(t.getMessage()); 
     System.out.println(((SQLGrammarException) t).getSQLState()); 
     System.out.println(((SQLGrammarException) t).getErrorCode()); 
     System.out.println(t.getCause()); 
    } 
    return new PersistenceMicrodataException(e.getMessage(), e); 
} 

誰かがこれで私を助けることができますか?

答えて

0

解決策が見つかりました。

public static PersistenceMicrodataException dealHibernateException(Throwable e) { 
    String concatError = ((SQLGrammarException) e).getSQL() + ((SQLGrammarException) e).getClass() + ((SQLGrammarException) e).getCause(); 
    while (e != null) { 
     java.lang.System.out.println(concatError); 
     break; 
    }   
    Throwable t = ExceptionUtil.getCause(e); 
    return new PersistenceMicrodataException(concatError,t); 
} 
関連する問題