尝试在Java方法中实现SQLGrammarException
我试图在我的方法中实现SQLGrammarException。 此方法显示列错误,但我需要显示包含错误的列来自哪个过程尝试在Java方法中实现SQLGrammarException,java,hibernate,Java,Hibernate,我试图在我的方法中实现SQLGrammarException。 此方法显示列错误,但我需要显示包含错误的列来自哪个过程 public static PersistenceMicrodataException dealHibernateException(Throwable e) { e.printStackTrace(); Throwable t = ExceptionUtil.getCause(e); return new PersistenceMicrodat
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);
}
有人能帮我吗?我找到了解决办法
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);
}
我找到了解决办法
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);
}