2

I have the following error message when I try to establish a HTTP request connection:

ORA-29273: HTTP request failed ORA-06512: at "SYS.UTL_HTTP", line 1029 ORA-12545: Connect failed because target host or object does not exist ORA-06512: at line 10 .

Line 10 is the following:

req := UTL_HTTP.BEGIN_REQUEST('oracle.com'); 

Here is my pl/sql block:

DECLARE 
    req UTL_HTTP.REQ; 
    resp UTL_HTTP.RESP; 
    name_1 VARCHAR2(256); 
    value_1 VARCHAR2(1024); 
    v_msg VARCHAR2 (500);

BEGIN 
    req := UTL_HTTP.BEGIN_REQUEST('http://www.oracle.com'); 
    UTL_HTTP.SET_HEADER(req, 'User-Agent', 'Mozilla/5.0'); 
    UTL_HTTP.SET_FOLLOW_REDIRECT(req, 0); 
    resp := UTL_HTTP.GET_RESPONSE(req); 
    LOOP
        Utl_Http.read_text (resp, v_msg);
        DBMS_OUTPUT.put_line (v_msg);
    END LOOP;

    UTL_HTTP.END_RESPONSE(resp);
EXCEPTION
    WHEN Utl_Http.end_of_body
        THEN
        NULL; 
END;
Ollie
  • 17,058
  • 7
  • 48
  • 59
Shaban Mousa
  • 154
  • 1
  • 2
  • 8
  • 1
    That code works. Are you sure you can resolve that domain name from that machine with your Oracle user? – Mat Dec 11 '11 at 10:27
  • how can i solve this err NO , it seems no ORA-29273: HTTP request failed ORA-06512: at "SYS.UTL_HTTP", line 1029 ORA-12545: Connect failed because target host or object does – Shaban Mousa Dec 11 '11 at 10:43
  • 2
    If you can't resolve the domain, or connect to that URL from the Oracle server's user account, you can't "solve" this error. You need to find out why you can't resolve that address or connect to that host - and this has nothing to do with Oracle (or programming). – Mat Dec 11 '11 at 10:47
  • unfortunately, I'm new to oracle world , I knowly only pl/sql . – Shaban Mousa Dec 11 '11 at 10:55
  • 1
    Once more: this error is not an error with the pl/sql code. – Mat Dec 11 '11 at 10:56
  • But there is an error waiting to happen. `dbms_output.put_line` can output maximum 255 characters. The variable you're outputting, `v_msg` is 500 characters meaning you're setting yourself up for this to break in a few minutes / days / weeks / months etc time. – Ben Dec 11 '11 at 17:52
  • Hello Ben , I tried your solution and it didnot work . any help is appreciated . – Shaban Mousa Dec 12 '11 at 06:27
  • THIS is the err msg : ORA-29273: HTTP request failed ORA-06512: at "SYS.UTL_HTTP", line 1029 ORA-12545: Connect failed because target host or object does not exist ORA-06512: at line 10 – Shaban Mousa Dec 12 '11 at 06:30
  • @ShabanMousa ( you need to put an @ in front of the person's name if you want them to see it ). My comment wasn't a solution ( that's why it was a comment ); it was a point that even if you solve your problem then your code is still buggy and will, at some point in the future, fail. `dbms_output` is usually the wrong way to go with prod code. – Ben Dec 18 '11 at 15:01
  • As already explained, log on to the actual Oracle server, open a web browser and check that you can access Oracle.Com If not, this is a network issue and is not an Oracle problem at all. – Nick.Mc Jan 11 '16 at 08:29
  • This is a 5+-year-old networking problem with no accepted answer. Voting to close. – Bob Jarvis - Слава Україні May 16 '16 at 17:08

1 Answers1

0

the code seems fine to me...

the reason of this error is outside the code you show:

The system this code is run on (the DB server) must be able to resolve the domain name - which has nothing to do with Oracle...

To solve this you need to setup DNS / hosts correctly on the machine / in the OS!

Yahia
  • 69,653
  • 9
  • 115
  • 144