java.sql.SQLException:ORA-06550:第 1 行,第 13 列:授予用户对 EXECUTE 包的权限后
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30249225/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.sql.SQLException: ORA-06550: line 1, column 13: After granting user permission to EXECUTE package
提问by corporateWhore
I've spent months developing a JAVA application with a Oracle db back-end. I am using Netbeans as my IDE and Oracle 12c on a laptop as my database. All PL/SQL has been compiled with no errors.
我花了几个月的时间开发一个带有 Oracle 数据库后端的 JAVA 应用程序。我使用 Netbeans 作为我的 IDE,使用笔记本电脑上的 Oracle 12c 作为我的数据库。所有 PL/SQL 都已编译无错误。
After extensive testing (logged in as the schema owner), I attempted to add a user. I created the user, logged in as SYS_DBA, using CREATE USER E566299 IDENTIFIED BY tempPswrd
, then granted permission using GRANT CREATE SESSION
and GRANT EXECUTE ON C##FAI_CODE.FAI_ADMIN_PKG TO E566299
and received Grant succeeded
confirmation.
经过大量测试(以架构所有者身份登录),我尝试添加一个用户。我创建了用户,以 SYS_DBA 身份登录,使用CREATE USER E566299 IDENTIFIED BY tempPswrd
,然后使用GRANT CREATE SESSION
和授予权限GRANT EXECUTE ON C##FAI_CODE.FAI_ADMIN_PKG TO E566299
并收到Grant succeeded
确认。
I login to my application, as this new user, with no errors using the following:
我以这个新用户的身份登录到我的应用程序,使用以下命令没有错误:
private static Connection getDbConn(String user, String password) throws SQLException{
OracleDataSource ods = null;
Connection dbConn = null;
user = "c##" + user;
ods = new OracleDataSource();
ods.setURL("jdbc:oracle:thin:@//localhost:1522/orcl.global.ds.XXXXXXXX.com");
ods.setUser(user);
ods.setPassword(password);
dbConn = ods.getConnection();
return dbConn;
}
Then it throws an error on the first package procedure call:
然后它在第一个包过程调用时抛出错误:
java.sql.SQLException: ORA-06550: line 1, column 13: PLS-00201: identifier 'FAI_ADMIN_PKG.CHECK_USER_FOLLOWED' must be declared ORA-06550: line 1, column 7: PL/SQL: Statement ignored
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399) at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1017) at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:655) at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:249) at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:566) at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:210) at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:53) at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:938) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1075) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3820) at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3923) at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:5617) at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1385) at faidb.FAIdb.checkSubscription(FAIdb.java:549) at faidb.faidbUI.run(faidbUI.java:186) at faidb.faidbLogin$3.run(faidbLogin.java:133) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
java.sql.SQLException:ORA-06550:第 1 行,第 13 列:PLS-00201:必须声明标识符“FAI_ADMIN_PKG.CHECK_USER_FOLLOWED” ORA-06550:第 1 行,第 7 列:PL/SQL:忽略语句
在 oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450) 在 oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399) 在 oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall7.java:101) ) 在 oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:655) 在 oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:249) 在 oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java) 566) 在 oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:210) 在 oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:53) 在 oracle.jdbc.driver.T4CCallableCCallableStatement.java:210) :938) 在 oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1075) 在 oracle.jdbc.driver.OraclePreparedStatement。executeInternal(OraclePreparedStatement.java:3820) at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3923) at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:5617) at oracle.jdbc.Statement.WOraclePreparedStatement.execute(OraclePreparedStatement.java:3923) .execute(OraclePreparedStatementWrapper.java:1385) at faidb.FAIDb.checkSubscription(FAIdb.java:549) at faidb.faidbUI.run(faidbUI.java:186) at faidb.faidbLogin$3.run(faidbLogin.java:133) java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)5617) 在 oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1385) 在 faidb.FAIdb.checkSubscription(FAIdb.java:549) 在 faidb.faidbUI.run(faidb$UI.java:186.faidbfaid) .run(faidbLogin.java:133) 在 java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)5617) 在 oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1385) 在 faidb.FAIdb.checkSubscription(FAIdb.java:549) 在 faidb.faidbUI.run(faidb$UI.java:186.faidbfaid) .run(faidbLogin.java:133) 在 java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
I'm at a loss, I've tried every possible combination of grant wording, all caps, all lowercase, single quotes, double quotes, with the schema owner name prefix C##FAI_CODE.FAI_ADMIN_PKG
, without FAI_ADMIN_PKG
, nothing will allow this new user to execute the package.
我不知所措,我已经尝试了所有可能的授权措辞组合,全部大写,全部小写,单引号,双引号,带有架构所有者名称前缀C##FAI_CODE.FAI_ADMIN_PKG
,没有FAI_ADMIN_PKG
,没有任何东西允许这个新用户执行包。
I've spent considerable time on this project and am near panic that no one will be able to use it.
我在这个项目上花费了大量时间,并且几乎担心没有人能够使用它。
Question:
问题:
Why can't my newly created user execute a package after being granted permission?
为什么我新创建的用户被授予权限后不能执行包?
Edit:
编辑:
I get a NullPointerException
on the last line with the call to rset.close();
, the result set is never initialized but it doesn't throw a SQLException
我NullPointerException
在最后一行调用rset.close();
,结果集从未初始化但它不会抛出SQLException
public Vector<String> fillBox() throws SQLException, NullPointerException{
CallableStatement callStatement = null;
ResultSet rset = null;
String fillBox = "{call fai_admin_pkg.get_end_item_pn(?)}";
Vector<String> boxFill = new Vector<>();
try{
callStatement = conn.prepareCall(fillBox);
callStatement.registerOutParameter(1, OracleTypes.CURSOR);
callStatement.execute();
rset = (ResultSet) callStatement.getObject(1);
boxFill = buildRsVector(rset);
}
finally{
callStatement.close();
rset.close();
}
return boxFill;
}
That is called here:
这里被称为:
Vector<String> boxFill = new Vector<>();
try{
boxFill = uiInst.fillBox();
}catch(SQLException e){
JOptionPane.showMessageDialog(frame, e.getMessage());
}catch(NullPointerException e){
JOptionPane.showMessageDialog(frame, e.getMessage());
e.printStackTrace();
}
Here are my permissions as the new user...which do not include execute on the package?? I'm not understanding
这是我作为新用户的权限......其中不包括对包的执行??我不理解
采纳答案by corporateWhore
Problem solved. Not having a global synonym set or current_schema
for the new user's session set to the package owner results in any calls to the owners package procedures requiring the owner's prefix: <package owner>.<package>.<procedure>
. The calls I was making under the new user were only to <package>.<procedure>
resulting in a SQLException
being thrown because to the compiler that package doesn't exist.
问题解决了。没有设置全局同义词或current_schema
将新用户的会话设置为包所有者会导致对需要所有者前缀的所有者包过程的任何调用:<package owner>.<package>.<procedure>
。我在新用户下进行的调用只是<package>.<procedure>
导致SQLException
被抛出,因为编译器不存在该包。
Additionally, I will research both global synonyms and user sessions to avoid having to use this quick fix.
此外,我将研究全局同义词和用户会话以避免必须使用此快速修复。
Thanks for the help!
谢谢您的帮助!
回答by Yu Yenkan
create session just allow you to login to the database. you might need others permission to do what you want to do.
create session 只允许您登录到数据库。您可能需要其他人的许可才能做您想做的事情。
you can refer to this link for help
你可以参考这个链接寻求帮助
https://docs.oracle.com/javadb/10.8.3.0/ref/rrefsqljgrant.html
https://docs.oracle.com/javadb/10.8.3.0/ref/rrefsqljgrant.html