从Oracle DB触发器发出HTTP请求时出错-java.sql.SQLException:ORA-29273:HTTP请求失败ORA-12541:TNS:无监听器

问题描述 投票:0回答:1

我正在使用以下代码通过Oracle DB触发器进行http调用

create or replace TRIGGER TEST_TABLE_TRIGGER 
AFTER INSERT OR UPDATE OF VALUE ON TEST_TABLE 

for each row
DECLARE

  req utl_http.req;
  res utl_http.resp;
  buffer varchar2(4000); 
  url varchar2(4000) := 'http://localhost:8086/testMethod';

BEGIN
  req := utl_http.begin_request(url, 'GET',' HTTP/1.1');
  utl_http.set_header(req, 'content-type', 'application/json');
  res := utl_http.get_response(req);
  -- process the response from the HTTP call
  begin
    loop
      utl_http.read_line(res, buffer);
      dbms_output.put_line(buffer);
    end loop;
    utl_http.end_response(res);
  exception
    when utl_http.end_of_body 
    then
      utl_http.end_response(res);
  end;
END;

DBA团队已向数据库用户授予http权限(SQL>授予在UTL_HTTP上对userName;执行)。但是,我的应用程序日志中出现了以下错误(Springboot)

java.sql.SQLException: ORA-29273: HTTP request failed
ORA-12541: TNS:no listener
ORA-06512: at "SYS.UTL_HTTP", line 368
ORA-06512: at "SYS.UTL_HTTP", line 1118
ORA-06512: at "userName.TEST_TABLE_TRIGGER", line 9
ORA-04088: error during execution of trigger 'userName.TEST_TABLE_TRIGGER '

我尝试在Linux服务器上运行该应用程序,并使用有效的IP地址代替了本地主机('http://localhost:8086/testMethod'),并得到了相同的错误。

当我问DBA团队时,他们说数据库侦听器已启动并且正在端口15251791上运行。如何/在何处使用数据库侦听器端口使此代码起作用?

java oracle database-trigger ora-12541
1个回答
0
投票

[当我在DBS触发器中使用http://localhost:8086/testMethod URL在STS(Spring工具站点)中运行代码时,它在本地不起作用。但是,在将代码部署到Linux服务器并用Linux服务器的ip地址(http:// {serverIP}:8086 / testMethod)更新了localhost之后,它起作用了!我的错 !我一开始使用的网址错误。如果我在STS中运行代码,请让我知道是否知道如何使其在本地工作。

© www.soinside.com 2019 - 2024. All rights reserved.