“Access denied” while setting DBMS_XDB.SETHTTPORT

2019-08-08 15:35发布

问题:

I was logged in as a normal user into the database:

SQL> connect
Enter user-name: myusername
Enter passwort: 
Connected.

And then I tried to set the default http port like this:

SQL> Exec DBMS_XDB.SETHTTPPORT(3000);

But I got the following error message:

ERROR at line 1:
ORA-31050: Access denied
ORA-06512: at "XDB.DBMS_XDB", line 528
ORA-06512: at "XDB.DBMS_XDB", line 667
ORA-06512: at line 1

What was going wrong? Perhaps because i am not an admin user? But how to add an admin user?

回答1:

Look at this:

SQL> conn hr/hr
Connected.
SQL> exec dbms_xdb.sethttpport(3000);
BEGIN dbms_xdb.sethttpport(3000); END;

*
ERROR at line 1:
ORA-31050: Access denied
ORA-06512: at "XDB.DBMS_XDB", line 528
ORA-06512: at "XDB.DBMS_XDB", line 667
ORA-06512: at line 1


SQL> conn / as sysdba
Connected.
SQL> exec dbms_xdb.sethttpport(3000);

PL/SQL procedure successfully completed.

SQL> grant execute on dbms_xdb to hr
  2  /

Grant succeeded.

SQL> conn hr/hr
Connected.
SQL> exec dbms_xdb.sethttpport(3002);
BEGIN dbms_xdb.sethttpport(3002); END;

*
ERROR at line 1:
ORA-31050: Access denied
ORA-06512: at "XDB.DBMS_XDB", line 528
ORA-06512: at "XDB.DBMS_XDB", line 667
ORA-06512: at line 1


SQL> conn / as sysdba
Connected.
SQL> grant sysdba to hr
  2  /

Grant succeeded.

SQL> conn hr/hr as sysdba
Connected.
SQL> exec dbms_xdb.sethttpport(3003);

PL/SQL procedure successfully completed.

So you must have the SYSDBA privilege to execute this package.