Are you getting "Unable to connect" error with Oracle and cannot figure out why?
Monday, November 02, 2009 8:51 PM
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
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).
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!