Click here to Skip to main content
Licence 
First Posted 5 Sep 2003
Views 54,257
Bookmarked 20 times

Auto-discover Oracle TNS service names with COSidHelper class

By | 5 Sep 2003 | Article
An article on how to discover Oracle TNS service names.
 
Part of The SQL Zone sponsored by
See Also

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

Member

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

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generalhelp please. PinmemberM_Nuaimi15:14 26 Apr '06  
GeneralOracle SID is showning NO records Pinmemberlovix6:35 6 May '05  
GeneralRe: Oracle SID is showning NO records PinmemberChasCurry5:37 4 Aug '05  
GeneralRe: Oracle SID is showning NO records PinmemberMachhaPuchhre18:11 20 Dec '05  
QuestionWhat is it? PinsitebuilderUwe Keim3:31 7 Sep '03  
AnswerRe: What is it? PinsitebuilderUwe Keim8:12 7 Sep '03  
GeneralRe: What is it? PinmemberSébastien Lorion9:58 7 Sep '03  

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

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