[英]Procedure in DB not working when called from Java
I have an Java application running on a Weblogic Server and Connecting to Oracle 11g DB server. 我有一个在Weblogic服务器上运行并连接到Oracle 11g DB服务器的Java应用程序。
In the application i make a call to a DB Procedure and pass a parameter to it which communicates and calls multiple other procedures. 在应用程序中,我调用了一个DB Procedure,并向其传递了一个参数,该参数可通信并调用多个其他过程。
When i test the Procedure independently, it works perfectly and as expected. 当我独立测试该程序时,它可以完美且按预期运行。
The issue comes when i call the Procedure from Java Application. 当我从Java应用程序调用过程时,就会出现问题。
The Procedure gives an error: 该过程给出了一个错误:
ORA-06508: PL/SQL: could not find program unit being called ORA-06508:PL / SQL:找不到正在调用的程序单元
The Backtrace leads to a call to a procedure that exists in another Schema and has a synonym in my current schema. Backtrace导致对另一个模式中存在的过程的调用,该过程在我当前的模式中具有同义词。
Please help if anybody else has faced the same issue or a similar one. 如果其他人遇到过相同或相似的问题,请提供帮助。
Edit#1: Sample Code for Calling DB Proc 编辑#1:调用DB Proc的示例代码
CallableStatement cstmt = null;
private Connection dbConn = null;
HashMap hashMap = new HashMap();
hashMap.put(DBDRIVER, driverType);
hashMap.put(USERID, userName);
hashMap.put(PASSWORD, password);
hashMap.put(SID, dbName);
hashMap.put(IPADDRESS, intDBServer);
hashMap.put(PORT, dbPort);
dbConn = (Connection)cmmObj.connect(hashMap);
cstmt = dbConn.prepareCall(queryToRun);
cstmt.setString(1, ReqId);
cstmt.executeUpdate();
Proc Call is { call Proc_CALL(?) } 程序调用为{调用Proc_CALL(?)}
在我看来,您的同义词似乎是错误的方式-调用模式需要被调用过程的同义词+执行权限。
I have probably found the issue. 我可能已经找到了问题。 Although it seams weird to hear it but it seems to work: 尽管听起来有些奇怪,但似乎可行:
The system i was working on has 3 Schema in connection. 我正在研究的系统具有3个架构的连接。
One is the Staging Schema from which all the calls are made. 一种是从中进行所有调用的登台模式。 Second is the Main Schema to which calls were made. 其次是调用的主架构。 The Called Procedure existed in this Schema. 该模式中存在被调用的过程。
The third is another schema where a procedure existed that was being called from Main Schema Procedure. 第三个是存在另一个已从主模式过程调用的过程的模式。
Simplified: 简化:
StageSchema.Caller(Synonym)-->> StageSchema.Caller(同义词)->>
MainSchema.Proc_Call(Procedure)-->> MainSchema.Proc_Call(过程)->>
CoSchema.insideCall(Procedure). CoSchema.insideCall(过程)。
The Grants to the CoSchema were available to the Main Schema, but not to the Stage Schema. 对CoSchema的授予对主模式可用,但对阶段模式不可用。
Although as per theory if Any Procedure is being granted to a schema then all inside calls to any other procedures should not matter. 尽管按照理论,如果将任何过程授予某个模式,那么对任何其他过程的所有内部调用都应该无关紧要。
but in this case when i gave the grant to Stage Schema, then everything seemed to work perfectly. 但是在这种情况下,当我将授权授予Stage Schema时,一切似乎都可以正常运行。
If any one has a solution to this then please share the reason for the same. 如果有人对此有解决方案,请分享原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.