I use sql-developer to connect to several different oracle databases with several different users. The connection info is kept in a tnsnames.ora
file so that when a database changes servers, I don't have to manually update all my connections to it. I recently updated my tnsnames file, and now there are 2 entries in the network alias list for each o开发者_运维百科ne that should be there. The 2nd entry appears to work (IE passes the test when I test the connection). However, by default, it seems to choose the first entry, which doesn't work.
I suspect this is due to the answer here: Oracle TNS names not showing when adding new connection to SQL Developer however, that answer doesn't address how to fix that problem.
So, how do I completely clear the network alias list and force it to re-load from the file?
It was grabbing an old copy of tnsnames.ora_OLD that I had in the same folder. According to:
http://forums.oracle.com/forums/thread.jspa?threadID=1017751
"There is a longstanding feature with SQL Developer's TNS Names functionality where SQL Developer will find all of the matching tnsnames.ora* files in the TNS Admin directory and list the contents of all of them. For example, all of the TNS aliases defined in TNSNAMES.ORA, TNSNAMES.ORA~ and TNSNAMES.ORA.201001210957 will be included in the Network Alias list."
Deleting that old file removed the extra entries.
I found that duplicated TNS names came from following two files; tnsnames.ora AND tnsnames.~ora
Two options;
option 1. delete file " tnsnames.~ora"
option 2. if you have to keep this " tnsnames.~ora" in the folder, then rename it to like "tnsnames~ora.txt"
** Please note, if you rename it "tnsnames.~ora.txt", it will still shows duplicated. My understanding is that if filename start with "tnsnames" and ends with "ora", it will gives you duplicated TNS names.
精彩评论