Oracle FAQ Your Portal to the Oracle Knowledge Grid

Home -> Community -> Usenet -> c.d.o.server -> Re: Any APIs?

Re: Any APIs?

From: Rauf Sarwar <>
Date: 7 Jul 2002 10:01:19 -0700
Message-ID: <>

"Howard J. Rogers" <> wrote in message news:<ag8oo2$m60$>...
> "Karen" <> wrote in message
> > No API. Even if such API existed it would be clumsy. There is a lot
> > of clauses in these files, and an API would have to have calls to encode
> > them.
> >
> > Besides, Oracle is trying to get rid of the files, make this automatic.
> >
> Whoa! You'll have to run that one pass me again. Oracle are "trying to get
> rid" of tnsnames.ora and listener.ora??
> I don't think so.
> They may be trying to get rid of static SID declarations in the
> listener.ora. But that's about it. Service names need resolving. There will
> *always* be a need therefore for a resolving mechanism. TNSNAMES is just a
> resolving mechanism. There are others (names server, etc). But tnsnames is
> basic, functional and ain't going nowhere soon.
> Likewise... the listener will always be with us, and will always need
> configuring if the defaults aren't appropriate to your needs.
> Regards
> > NetAssistant can generate files but provides limited functionality.
> >
> > Janardhan wrote:
> >
> > > Does Oracle Provide any API to modify TNSNAMES.ORA and LISTENER.ORA?
> >

Net8 assistant is pretty much the best way to do it. Idea is to use something which is already there...why re-invent the wheel.

However, if you are curious like me and want to kick around with the idea then one way would be to successfully parse the tnsnames.ora file. Once parsed you can change the parameters in individual connect descriptors and save the file. I don't know what kind of effort would

there be. Since there is no public API provided by Oracle to parse a
tnsnames.ora file, I built a parser in java which parses the
tnsnames.ora file and have few functions to work with like,

  1. Returns a list of all service_names/aliases in the file.
  2. Returns full connect descriptor from "=(DESCRIPTION..." to last closing "...)" parethesis given an alias/service_name. This is what you can use and further parse the connect descriptor.
  3. Builds the url and returns a java Connection object (oci8/oci7 or thin) given only an alias/service_name. etc

If you want to play around with it, email me and I can send it to you with documentation. It's a freeware so you can do whatever you like with it. It took me approx 25 hours to program it. Tested on version 7.3.x to 8.1.x. and requires java 1.2.1 and above.

//Rauf Sarwar Received on Sun Jul 07 2002 - 12:01:19 CDT

Original text of this message