Click here to Skip to main content
Click here to Skip to main content

Auto-discover Oracle TNS service names with COSidHelper class

By , 5 Sep 2003
 

Sample Image - OSidList.jpg

Introduction

This article introduces a class which automatically constructs Oracle TNS service names defined on a local machine.

Background

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 COSidHelper class.

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:

COSidHelper osidHelper;
for( int nIndex =0; nIndex < osidHelper.m_strArray.GetSize(); nIndex++ )
{
    // ...
}

For test purposes, I also put in a Display() method there.

Points of interest

  1. Check directory existence. In older Oracle client installs, tnsnames.ora is under net80, in newer version, it is under network directory.
  2. RegistryKey operation.
  3. Parser for Oracle tnsnames.ora file structure.

History

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

li@agileinfollc.com
Web Developer
United States United States
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.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Generalhelp please.memberM_Nuaimi26-Apr-06 15:14 
GeneralOracle SID is showning NO recordsmemberlovix6-May-05 6:35 
GeneralRe: Oracle SID is showning NO recordsmemberChasCurry4-Aug-05 5:37 
GeneralRe: Oracle SID is showning NO recordsmemberMachhaPuchhre20-Dec-05 18:11 
QuestionWhat is it?sitebuilderUwe Keim7-Sep-03 3:31 
AnswerRe: What is it?sitebuilderUwe Keim7-Sep-03 8:12 
GeneralRe: What is it?memberSébastien Lorion7-Sep-03 9:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130617.1 | Last Updated 6 Sep 2003
Article Copyright 2003 by li@agileinfollc.com
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid