使用ftp软件包的Oracle 11g过程错误

时间:2012-03-26 09:16:36

标签: oracle plsql acl plsqldeveloper

我遇到了数据库问题(版本是Oracle 11g)。

我想做什么?

  • 我想使用程序将文件上传到ftp服务器。

我是怎么做到的?

  • 首先,我已下载 ftp.pks ftp.pkb 文件,我使用@ **。pks导入此软件包。

  • 然后我编写如下的程序:

    DECLARE
      l_conn  UTL_TCP.connection;
    BEGIN
      l_conn := ftp.login('192.168.1.102', '21', 'tony', 'tony');
      ftp.ascii(p_conn => l_conn);
      ftp.put(p_conn      => l_conn,
              p_from_dir  => 'MY_DOCS',
              p_from_file => 'aaa.txt',
              p_to_file   => 'test_put.txt');
      ftp.logout(l_conn);
    END;
    
  • 当我运行它时,控制台会给我这个错误信息

    ORA-24247: network access rejected by ACL
    ORA-06512: at "SYS.UTL_TCP", line 17
    ORA-06512: at "SYS.UTL_TCP", line 246
    ORA-06512: at "SCOTT.FTP", line 76
    ORA-06512: at line 4
  • 因此,我使用以下代码创建了ACL规则:

    begin
    
         DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(
         acl          => 'ftp_conn.xml',
         description  => 'ftp connection',
         principal    => 'SCOTT',
         is_grant     => TRUE,
         privilege    => 'connect');
    
         DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(
          acl         => 'ftp_conn.xml',
          host        => '192.168.1.102',
          lower_port  => 21,
          upper_port => 21);
    
    end;
    

但是,当我再次运行ftp代码时,它也会显示错误,所以我想知道如何解决这个问题。

ACL可以允许TCP连接,但是当我使用ftp包并调用“ftp.put”时,控制台输出

error at 1 line:
ORA-29260: network error:not connected
ORA-06512: at "SYS.UTL_TCP", line 212
ORA-06512: at "SYS.UTL_TCP", line 432
ORA-06512: at "SCOTT.FTP", line 413
ORA-24247: Network access rejected by acl
ORA-06512: at "SCOTT.FTP", line 491
ORA-06512: at line 6

1 个答案:

答案 0 :(得分:0)

尝试添加resolve特权(虽然听起来很奇怪......):

begin
 DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(
 acl          => 'ftp_conn.xml',
 description  => 'ftp connection',
 principal    => 'SCOTT',
 is_grant     => TRUE,
 privilege    => 'connect');

 DBMS_NETWORK_ACL_ADMIN.add_privilege ( 
acl         => 'ftp_conn.xml', 
principal   => 'SCOTT',
is_grant    => FALSE, 
privilege   => 'resolve', 
position    => NULL, 
start_date  => NULL,
end_date    => NULL);

 DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(
  acl         => 'ftp_conn.xml',
  host        => '192.168.1.102',
  lower_port  => 21,
  upper_port => 21);

end;
/
COMMIT;