Problems with calling the "package stored procedure" in Java ORA-04068: existing state of packages has been discarded

Source: Internet
Author: User
Status quo: 1. project: when the web is started, compile the package stored procedure: salsel. pac_real_usertag_test ". When the stored procedure is called for the first time, the following error occurs:" cause: Java. SQL. sqlexception: ORA-04068: existing state of packages has been discardedORA-04061: existing state of package body "salsel. pac_real_usertag_test "has been invalidatedORA-04065: not executed, altered or dropped package body" salsel. pac_real_usertag_test "ORA-06508: PL/SQL: cocould not Find Program unit being called: "salsel. pac_real_usertag_test" ORA-06512: At Line 1 "the call is successful again. 2. Problem Analysis: Because package is used in the "package stored procedure" and global variables are used. When Oracle compiles the stored procedure, the original state of the stored procedure is set to invalid, and a new state stored procedure is created. As a result, the "package stored procedure" in the invalid state is called during the first call ". The second "package stored procedure" that fails to be called ". 3. Solution: http://blog.csdn.net/ningxuezhu/article/details/8880545 http://database.ctocio.com.cn/tips/14/8106014.shtml Article Provides three solutions. Solution 3 is considered the most appropriate. You need to use the following method to determine the need to surround the notification PublicStaticBooleanReturnexecutionrequired (sqlexception e ){ Boolean Returnvalue = "72000" . Equals (E. getsqlstate () & E. geterrorcode () = 4068 ; Return Returnvalue; } However, when our Framework calls a stored procedure exception, the exception thrown is not sqlexception, but busiexception. In this way, the corresponding errorcode and sqlstate cannot be obtained. 4. the final method is adopted. Currently, our method is to use basedao. getconnection (), open the link by yourself, call the "package stored procedure", and then close the connection. however, there is a problem that frequent enabling of database links and closing of database links will cause resource consumption. check whether sqlexception can be thrown at the framework level.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.