When querying data on the client, there may be clearly indicated data, but it still shows that no data is found, and you can click to query or check it several times again. It is very depressing to check the server logs, the following error was found:
[Java]
View plaincopyprint?
-
- 2011-01-07
08:49:31,604Error [stderr] java. SQL. sqlexception: ora-04068:
Existing State of packages has been discarded
-
- Ora-04061: Existing State
PackageBody"Isgis. gis_dist_stat"Has been invalidated
- Ora-04065: Not executed, altered or dropped
PackageBody"Isgis. gis_dist_stat"
-
- Ora-06508: PL/SQL: cocould not find Program unit being called:
"Isgis. gis_dist_stat"
-
- Ora-06512:
"Isgis. vehicle_test_proccccc", Line100
-
- Ora-06512: At Line1
08:49:31, 604 error [stderr] Java. SQL. sqlexception: ORA-04068: existing state of packages has been discarded <br/> ORA-04061: existing state of package body "isgis. gis_dist_stat "has been invalidated <br/> ORA-04065: not executed, altered or dropped package body" isgis. gis_dist_stat "<br/> ORA-06508: PL/SQL: cocould not find Program unit being called:" isgis. gis_dist_stat "<br/> ORA-06512: At" isgis. vehicle_test_proccccc ", line 100 <br/> ORA-06512: At line 1
The error message is isgis. the status of the gis_dist_stat package is invalid. That is to say, if dbserver re-compiles the package, this exception occurs. If this error is not reported again, the reason is that when the package is compiled, the package status will be cached. When you re-compile the package, the previously cached package status will change to old, and the newly compiled package will become new.ProgramWhen you request this package, the old one is loaded, and the old one is marked as invalid. Therefore, an error is returned. When you query the package again, the program already knows that this package is invalid. Therefore, if you reload new, no error will be reported. There are roughly three solutions:
1. Set the used package to a stateless package. That is to say, you cannot set global variables in the package. In this way, even if the package is re-compiled, the above errors will not occur, this must be taken into account during programming, but unfortunately, I did not consider this point in the current program design. The package size is large and global variables are everywhere!
2. Place the global variables in the package into a new package. The current package does not set global variables. When the current package needs global variables, it is retrieved from the new package, as long as the package where the global variable is located is not re-compiled, no exception will occur. I think this method is better, because there is no global variable in the package, isn't it a lot of repetitive work? However, at present, the global variables in my program are everywhere, which is too troublesome to change. It seems that it is still necessary to consider a more comprehensive aspect during program design!
3. If the Spring framework is used in your project, you will surely know the spring surround notification. The so-called surround notification means that this notification will be called before and after the method is executed. In this notification, you can change the parameters of the input method, or modify the return value of the method. Of course, there are pre-notifications and post-notifications. If you do not know, check the information yourself, I intend to add a surround notification to all methods that need to call the package, and then determine whether a 4068 exception has occurred after the method is executed. If this exception occurs, I will execute it again, in this way, no data can be found, andSource codeNo modification is required. You only need to add a configuration file and a class. If spring is not used, you can find a solution. You can determine whether a 4068 exception occurs during execution, then re-query the database. The general idea is that there is another way on the Internet. I think it is also good to rewrite the methods for executing database operations in the callablestatement, preparedstatement, and statement classes, then, you can determine whether a 4068 exception has occurred. If yes, you must execute it again. This requires that you use the self-overwritten class to perform database operations where a 4068 exception may occur, if the project is huge and has taken shape, you will be dizzy. If 4068 exceptions are considered during project construction, this is not a good method.
Summary:
To sum up, I personally think that if it is convenient to change the database, we should try to use 2nd methods. If the database cannot let you change it, and the program has been formed, we cannot change the source in a wide range.CodeSo it is more cost-effective to use spring's surround notification!
Hey, it seems that if the database uses a package during project construction in the future, we should consider the 4068 exception, because it will be more difficult to change it after molding! I am also a cainiao. I hope the experts will correct what is wrong. Thank you!
Appendix:
Java code used to judge database 4086 exceptions:
[Java]
View plaincopyprint?
- Public Static
BooleanReturnexecutionrequired (sqlexception e ){
- BooleanReturnvalue ="72000". Equals (E. getsqlstate () & E. geterrorcode () =4068;
- ReturnReturnvalue;
- }