Search
Friday, March 02, 2001 ..:: Home ::.. Register  Login
   Calendar  
     
  
   Search  
     
  
   Disclosure  
     
  
   TechTidBits (Blog)  

Are you getting "Unable to connect" error with Oracle and cannot figure out why?

Nov 2

Written by:
Monday, November 02, 2009 8:51 PM  RssIcon

Are you getting a cryptic ORA-12154 error saying something like "TNS:could not resolve the connect identifier specified?"  If you are, I potentially have a solution for you, read on.

Today while working on a bug...uh..uh..."undocumented feature" (borrowing a term from Microsoft HAHA), I ran into a problem trying to connect to Oracle.

After setting up my tnsnames.ora file JUUUUUUUUUUUST like the one below

tnsnames file contents

I was getting an error when I tried to test it out using the ODBC manager in Control Panel (handy way to test db connectivity).

Oracle error Could Not Resolve The Connect Identifier Specified

Hey, I'm no Oracle DBA, so I asked our IT guy, and after cutting'n'pasting one of his tnsnames.ora and seeing it work (DOH!) I was naturally wondering what was different.  If you can't guess, I won't leave you hanging. 

It was/is the FREAK#$%^$%^#$%#$%^ING leading spaces in front of my name up above!  Ya, the TWO leading spaces in front of "perf" on line four above were the source of my "unable to conenct" to Oracle errors!!!!!!!!!!!!!!!!!!!!!!!!!!!  WTF?????????????!!!!!!!!!!!  WHO CODES CRAP LIKE THAT!!!!!!!!!!  

If you're going to let users create/modify/edit a text file, be sensitive to spaces AND IGNORE THEM (where appropriate, and in this case it's COMPLETELY APPROPRIATE to ignore those spaces).

Am I upset?  You bet!  I felt like an idiot when the IT guys' tnsnames.ora file worked and mine didn't, THEY WERE EFFECTIVELY IDENTICAL!  Yes, even the spaces ORACLE!  Figure it out you twits!

THERE, got that out of my system, now it's time to grab a coffee and get back to coding!  Hey, at least now I can connect to the DB and reproduce that undocument feature!

Tags:
Categories:
Location: Blogs Parent Separator TechTidBits

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Add Comment   Cancel 
     
  
Copyright 1999-2012 by PCHenry.com   Terms Of Use  Privacy Statement