Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: server IP adress and port

Re: server IP adress and port

From: Rauf Sarwar <rs_arwar_at_hotmail.com>
Date: 12 Aug 2005 08:40:16 -0700
Message-ID: <1123861216.294186.46410@g43g2000cwa.googlegroups.com>

jerry wrote:
> Uzytkownik Mark D Powell napisal:
> > You fail to list your Oracle version. On versions prior to 9 or 9.2 I
> > believe there is a way using java but I do not know it.
> >
>
> 9.2
>
> > With 9.2 (maybe 9) + you can use the following database call to get the
> > database server IP address
> >
> > select
> > utl_inaddr.get_host_address as hip
> > from
> > sys.dual
>
> it's work. Thanks!!!!
>
> >
> > I know of no query that will provide the Operating System Port number
> > in use, however you cannot get a connection to the database to issue a
> > query unless you know the port number to use to make a connection so
> > why do you need to query for it? The port number is most likely going
> > to be 1521.
> >
> > HTH -- Mark D Powell --
> >
>
> Why I need server IP adress and port? - so, I must write a function
> (Delphi) which get information about database server and actual session.
> Well, about session I can use sys_context function, about server IP
> adress - I can use your query. Now I need to get a port number. I know
> that in most often case it is 1521, but I neet do read this information
> from server and I do not know how.
>
> Thanks for the query!
> jerry

Which port no are you interested in?
1) Port where listener is listening? (e.g. 1521). 2) Server port where listener redirected after the successfull connection?
3) Client port?

1521 as previously stated is the listener port where listener listens for new connections (This is where you initially attempted the connection... Look at the PORT= value in your tnsnames.ora file). Upon successfull connection, listener redirects the communication to a different port. I don't believe this information is visible anywhere in the database. Try a sqlplus connection to the database over TCP. Then run netstat -a on your client machine. You will see something like,

TCP CLIENT:xxxx DATABASE_SERVER:xxxx ESTABLISHED

where CLIENT=Your client machine name, DATABASE_SERVER=Database server name and xxxx= actual client and server ports where the listener redirected. Same information is visible on the server also but in reverse order i.e.

TCP DATABASE_SERVER:xxxx CLIENT:xxxx ESTABLISHED

This is not a pretty solution but you could run the netstat -a via Java stored procedure (Runtime) object and parse the resultset for your machine. It is not be 100% accurate if you have more then one connection from the same machine to the same database.

Regards
/Rauf Received on Fri Aug 12 2005 - 10:40:16 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US