Shows short description for file

<< Back

Filename: (5,164 bytes)
Released: 29th October 2013, 4,852 downloads
Category: PHP

DownloadClick to download

       README for tnsparser.class - Last updated on 29-Oct-2013


This class was build to easily parse the Oracle TNS files, mainly for my
OIS2 application to have some kind of automatic detection of TNS names in
place. It is licensed under the BSD, so do what you want with it, but please
keep the copyright notice intact, thank you!

The class takes an tnsnames.ora file, parses it down to all components and
returns an associative array with all parsed data, indexed by the TNS name.

As many components inside a TNS name could be specified multiple times,
the returned array values are in fact arrays, too. Here's an example how
an resulting array may look like:

    [ORADEV] => Array
            [PROTOCOL] => Array
                    [0] => TCP

            [HOST] => Array
                    [0] =>

            [PORT] => Array
                    [0] => 1521

            [SERVER] => Array
                    [0] => DEDICATED

            [SERVICE_NAME] => Array
                    [0] => ORADEV.LOCAL

This is the parsing result of the following original TNS entry:

    (ADDRESS = (PROTOCOL = TCP)(HOST = = 1521))

The distribution provides an example taken from Oracle docs with multiple
host specifications, so you can see exactly how this all works.


Usage is rather simple, create a new instance from the class and call
the public method "ParseTNS()" with the path to your oracle tnsnames.ora
file, i.e.:

$TNS = new TNSParser;
$rc = $TNS->ParseTNS('/opt/oracle/product/11.2/network/admin/tnsnames.ora');

In case of an error the method throws an exception, so you should use a
try/catch block to react on errors.

I've successfully tested this class with a number of different and rather
complex TNSnames files, however no software is really bugfree, so if you
find a bug or have an idea how to improve this class, either do it on your
own or feel free to contact me on my homepage, which could be found under
the following URL:

Nothing more to say, I doubt that anyone really reads this file until
the end, so keep up coding :D

$Id: README 23 2013-10-29 20:52:14Z siegel $

<< Back