2

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

我想做什么?

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

我是怎么做的?

  • 首先,我已经下载了ftp.pksftp.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
4

1 回答 1

0

尝试添加解决权限(虽然听起来很奇怪......):

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;
于 2012-03-26T09:46:29.013 回答