java.sql.SQLException: ORA-06550: line 1, column 13: After granting user permission to EXECUTE package

主宰稳场 提交于 2019-12-12 13:14:08

问题


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.

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.

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)

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.

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

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


回答1:


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.

Additionally, I will research both global synonyms and user sessions to avoid having to use this quick fix.

Thanks for the help!




回答2:


create session just allow you to login to the database. you might need others permission to do what you want to do.

you can refer to this link for help

https://docs.oracle.com/javadb/10.8.3.0/ref/rrefsqljgrant.html



来源:https://stackoverflow.com/questions/30249225/java-sql-sqlexception-ora-06550-line-1-column-13-after-granting-user-permiss

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!