java调用“package存储过程”遇到的问题ORA-04068: existing state of packages has been discarded
2013-06-07 21:02
701 查看
现状:
1. 项目,调用"package 存储过程"问题如下:
当web处于启动状态,此时编译"package 存储过程:SALSEL.PAC_REAL_USERTAG_TEST",
第一次调用该存储过程时,报错:
“
Cause: java.sql.SQLException: ORA-04068: existing state of packages has been discarded
ORA-04061: existing state of package body "SALSEL.PAC_REAL_USERTAG_TEST" has been invalidated
ORA-04065: not executed, altered or dropped package body "SALSEL.PAC_REAL_USERTAG_TEST"
ORA-06508: PL/SQL: could not find program unit being called: "SALSEL.PAC_REAL_USERTAG_TEST"
ORA-06512: at line 1
”
再次调用则成功。
2. 问题分析:
由于“package 存储过程”中,使用package,并且使用了全局变量。当oracle编译此存储过程时,将此存储过程的原状态置为失效,重新创建了一个新的状态的存储过程。
导致,第一次调用时,调用的是失效状态的“package 存储过程”。第二次调用失效状态的“package 存储过程”。
3. 解决方案:
http://blog.csdn.net/ningxuezhu/article/details/8880545
http://database.ctocio.com.cn/tips/14/8106014.shtml
文章中提供了3种解决方案。方案3我们认为是最合适的。需要使用下面的方法,判断需要环绕通知
publicstaticboolean returnExecutionRequired(SQLException e){
boolean returnValue= "72000" .equals(e.getSQLState()) && e.getErrorCode()== 4068 ;
return returnValue;
}
但是,我们的框架,调用存储过程异常时,抛出的异常不是SQLException,而是BusiException。
这样,我们就无法获取对应的ErrorCode和SQLState。
4. 最终采用方法
目前,我们的方法是,使用baseDao.getConnection(),自己开启链接,调用“package 存储过程”,然后关闭Connection.
但是,这样有个问题,频繁的开启数据库链接,关闭数据库链接,会造成资源消耗。
看能否从框架层面,抛出SQLException。
1. 项目,调用"package 存储过程"问题如下:
当web处于启动状态,此时编译"package 存储过程:SALSEL.PAC_REAL_USERTAG_TEST",
第一次调用该存储过程时,报错:
“
Cause: java.sql.SQLException: ORA-04068: existing state of packages has been discarded
ORA-04061: existing state of package body "SALSEL.PAC_REAL_USERTAG_TEST" has been invalidated
ORA-04065: not executed, altered or dropped package body "SALSEL.PAC_REAL_USERTAG_TEST"
ORA-06508: PL/SQL: could not find program unit being called: "SALSEL.PAC_REAL_USERTAG_TEST"
ORA-06512: at line 1
”
再次调用则成功。
2. 问题分析:
由于“package 存储过程”中,使用package,并且使用了全局变量。当oracle编译此存储过程时,将此存储过程的原状态置为失效,重新创建了一个新的状态的存储过程。
导致,第一次调用时,调用的是失效状态的“package 存储过程”。第二次调用失效状态的“package 存储过程”。
3. 解决方案:
http://blog.csdn.net/ningxuezhu/article/details/8880545
http://database.ctocio.com.cn/tips/14/8106014.shtml
文章中提供了3种解决方案。方案3我们认为是最合适的。需要使用下面的方法,判断需要环绕通知
publicstaticboolean returnExecutionRequired(SQLException e){
boolean returnValue= "72000" .equals(e.getSQLState()) && e.getErrorCode()== 4068 ;
return returnValue;
}
但是,我们的框架,调用存储过程异常时,抛出的异常不是SQLException,而是BusiException。
这样,我们就无法获取对应的ErrorCode和SQLState。
4. 最终采用方法
目前,我们的方法是,使用baseDao.getConnection(),自己开启链接,调用“package 存储过程”,然后关闭Connection.
但是,这样有个问题,频繁的开启数据库链接,关闭数据库链接,会造成资源消耗。
看能否从框架层面,抛出SQLException。
相关文章推荐
- 解决ORA-04068 异常existing state of packages has been discarded
- ORA-04068: existing state of packages has been discarded
- 一次极其痛苦troubleshooting:ORA-04061: existing state of has been invalidated
- C#解决微信支付Exception has been thrown by the target of an invocation(调用的目标发生了异常)的问题
- 遇到问题----java.lang.IllegalStateException: getOutputStream() has already been called for this response
- 【java调用“package存储过程”遇到的问题】
- 遇到问题----java.lang.IllegalStateException: getOutputStream() has already been called for this response
- 【原创】遇到:Invalid layout of java.lang.String at value 这样的问题,该怎么办呢?
- 解决java.lang.IllegalStateException: The content of the adapter has changed but ListView...的问题
- Oracle 9i ORA-04062 timestamp of package SYS DBMS_SNAPSHOT_UTL has been changed ORA-06512 at SYS DBMS_SNAPSHOT
- java.lang.Process调用程序阻塞问题解决(刚刚遇到的问题,看有人解决了,转一下:) )
- java.lang.IllegalStateException:The content of the adapter has changed but ListView did not receiv问题
- 解决java.lang.IllegalStateException: The content of the adapter has changed but ListView...的问题
- 解决java.sql.SQLException: ORA-01789: query block has incorrect number of result columns
- 【SSH问题】java.lang.IllegalStateException: Cannot call sendError() after the response has been committe
- 导入项目出现问题:An existing resource has been found at location
- 使用eclipse测试osgi遇到的问题--“Workbench has not been created yet”
- java 线程遇到的问题及解决方法 JNI调用
- java开发中常常遇到的内存溢出问题 OutOfMemory
- 解决Fragment相关问题,java-lang-illegalstateexception-activity-has-been-destroyed