java调用“package存储过程”遇到的问题ORA-04068: existing state of packages has been discarded
来源:互联网 发布:淘宝排名下降怎么补救 编辑:程序博客网 时间:2024/05/19 13:23
现状:
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我们认为是最合适的。需要使用下面的方法,判断需要环绕通知
public staticboolean returnExecutionRequired(SQLException e){
boolean returnValue="72000".equals(e.getSQLState()) && e.getErrorCode()==4068;
return returnValue;
}
但是,我们的框架,调用存储过程异常时,抛出的异常不是SQLException,而是BusiException。
这样,我们就无法获取对应的ErrorCode和SQLState。
4. 最终采用方法
目前,我们的方法是,使用baseDao.getConnection(),自己开启链接,调用“package 存储过程”,然后关闭Connection.
但是,这样有个问题,频繁的开启数据库链接,关闭数据库链接,会造成资源消耗。
看能否从框架层面,抛出SQLException。
- java调用“package存储过程”遇到的问题ORA-04068: existing state of packages has been discarded
- ORA-04068: existing state of packages has been discarded
- 解决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
- 【java调用“package存储过程”遇到的问题】
- Oracle 9i ORA-04062 timestamp of package SYS DBMS_SNAPSHOT_UTL has been changed ORA-06512 at SYS DBMS_SNAPSHOT
- An existing PostgreSql installation has been found... 的解决
- 【React Native】React Native之Navigator has been remove from this package...的问题
- Error: ORA-04062: timestamp of procedure has been changed
- oracle 的自定义的存储函数遇到的 package or function is in an invalid state
- 导入项目出现问题:An existing resource has been found at location
- 修改java项目名称后布署tomcat出现An existing resource has been found at location
- 遇到问题----java.lang.IllegalStateException: getOutputStream() has already been called for this response
- 完全删除已安装的postgresql,防止重新安装时出现“An existing installation has been found...”
- An existing resource has been found at location:tomcat 的解决方法!
- ibatis调用带游标的存储过程package
- “Location of the Android SDK has not been set up in the preferences”问题的解决
- 使用 Spring Batch 构建企业级批处理应用: 第 2 部分
- Asp.Net页面传值的几种方式
- 三步堵死SQL注入漏洞
- stm32 EXTI对应的中断函数
- Django自定义过滤器
- java调用“package存储过程”遇到的问题ORA-04068: existing state of packages has been discarded
- SQL注入实战---利用“dbo”获得SQL管理权限和系统权限
- c数据结构之单链表操作
- js头像预览
- Linux里如何查找文件内容
- C sharp中如何调用C++编写的DLL
- pinyin4j的使用例子:将中文转换成拼音
- linux下使用3G拨号上网
- SQL注入渗透某网络安全公司的网站全过程