This article introduces a class which automatically constructs Oracle TNS service names defined on a local machine.
I always wonder how to find out how many Oracle instances are defined programmatically. Using SQL*Plus, one has to type in the Oracle instance name. In some cases, because we may have a lot of databases, we often make mistakes. One day I decided to write something to automatically discover all the Oracle instances defined on the local machine. So here comes
Using the code
This code is very easy to use, you add SidHelper.h and SidHelper.cpp into your project, then when you need to display Oracle TNS service names, simply construct an instance of this class like this:
for( int nIndex =0; nIndex < osidHelper.m_strArray.GetSize(); nIndex++ )
For test purposes, I also put in a
Display() method there.
Points of interest
- Check directory existence. In older Oracle client installs, tnsnames.ora is under net80, in newer version, it is under network directory.
- Parser for Oracle tnsnames.ora file structure.
I wrote this class long time ago for a software called PowerQuery). Today finally got time to share it with CodeProject community. You can use this class for free.
LI is a architect of several database-centric tools and technologies. He has been programming since 1995. He is a Microsoft Certified Solution Developer (MCSD), MCSD.NET, SCJP, SCJD and OCDBA.
His programming experience includes C/C++, C#, MFC, ASP, VB and Perl. He has worked on Solaris, AIX, HPUX and various Windows, and found Windows is the easiest one to work with.
He has over 8 years of database experiences in Oracle, SQL Server, DB2 and other DBMS.
LI co-founded AgileInfoSoftware LLC (http://www.agileinfollc.com) in 2003. He is responsible for the overall vision and development strategy of the company.