繁体   English   中英

Error While making http request from Oracle DB Trigger - java.sql.SQLException: ORA-29273: HTTP request failed ORA-12541: TNS:no listener

[英]Error While making http request from Oracle DB Trigger - java.sql.SQLException: ORA-29273: HTTP request failed ORA-12541: TNS:no listener

我正在使用以下代码通过 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 团队已向 DB 用户授予 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 地址而不是 localhost( 'http://localhost:8086/testMethod' )并得到相同的错误。

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

当我在 DB 触发器中使用http://localhost:8086/testMethod URL 在 STS(Spring Tool Site)中运行代码时,它在本地不起作用。 但是,在我在 Linux 服务器中部署代码并使用 linux 服务器的 ip 地址(http://{serverIP}:8086/testMethod)更新本地主机之后我的错。 我一开始使用了错误的 URL。 当我在 STS 中运行代码时,如果您知道如何使其在本地工作,请告诉我。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM