簡體   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