首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

请教怎么得到Oracle SQLException的errorCode, 用SQLException.getErrorcode() 总是返回0

2012-04-26 
请问如何得到Oracle SQLException的errorCode, 用SQLException.getErrorcode() 总是返回0请问如何得到Orac

请问如何得到Oracle SQLException的errorCode, 用SQLException.getErrorcode() 总是返回0
请问如何得到Oracle SQLException的errorCode, 用SQLException.getErrorcode() 总是返回0

例如有如下Oracle Exception:
org.jboss.util.NestedSQLException: Could not create connection; - nested throwable: (java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
pacwas1:1521:testdb
); - nested throwable: (org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
xxx:1521:xxx
))

当Catch到这个SQLException并且使用getErrorcode() 总是返回0,但我期待的是ORA-12505,请问有好的方法吗?


[解决办法]
try{...}
catch(SQLException e) {System.out.println(e.getMessage);}

热点排行