【发布时间】:2021-10-10 12:09:00
【问题描述】:
我的代码会抛出包装在 RuntimeException 中的 SQLException,例如:
} catch (RuntimeException e) {
Throwable t = e.getCause();
while ((t != null) && !(t instanceof java.sql.SQLException)) {
t = t.getCause();
}
. . . Someother code
if (SQLState==) {
//throw new custom exception based on SQLState);
}
如何在 if 循环中获取 SQLState?不知何故,while循环t为null。
【问题讨论】:
标签: java exception jdbc runtimeexception sqlexception