问题
Here are the details:
- I installed the oracle instant client 11.2.0.2.0 from the OTN download page on a windows 7 64 bit vm (vmware).
- I am trying to to connect to a remote oracle database, and I can successfully connect with one program using TNS, but not with SQL*Plus and other applications.
- Trying to connect with SQL*Plus, using schema@servicename, password, etc, gives the above error.
- To connect via SQL Developer, normally I would use the basic connection info and not rely on tnsnames, but trying a normal connection gives me:
io error: unknown host specified
. SQL Developer can successfully connect and query database if i use the TNS protocol. - Trying from other programs gives me the same error I got with SQL*Plus. Same when trying with the service name from tnsnames.
This is obviously quite frustrating for it to work one way and not the other. I followed all the normal instructions for using the instant client, the directory with instantclient has been addded to the PATH, a TNS_ADMIN entry has also been created, with the directory to the tnsnames.ora file
回答1:
Well, on a whim, I went to changing everything in my setup to match an windows 2003 server that i had setup with instant client before. The main changes were putting the instant client in a folder at the root of the drive (not program files/oracle/etc), but c:/oracle, i know ive seen other posts saying that oracle was particular about characters in the directory path, maybe spaces are a no-no too?
I also add a bunch more environmental variables, anythign that was on the other machine, ORACLE_HOME (to root of instance), SQL_PATH (same), and added the root of the directory to the PATH system variable, not just the folder with the instantclient files. Anyways, I'm happy its working, anyone one of these changes could have been it though-
回答2:
You may use ProcessMonitor and look at what your sqlplus process is doing. In my case TNS_ADMIN was correctly defined but, by mistake, my tnsnames.ora and sqlnet.ora had a stupid ".txt" extension, added by default by notepad when I created those files. And because "Windows Explorer" has the "Hide extensions for known file types" option set by default, the naming error wasn't obvious at all.
回答3:
I installed the 12.1 instant client. For me, the problem was solved by creating \network\admin\tnsnames.ora file. Here's the PowerShell I used:
$source = "C:\Users\USER1\Desktop\tnsnames.ora"
$target = "C:\oracle\product\12.1.0\client_1\network\admin"
mkdir $target
copy-item $source $target
来源:https://stackoverflow.com/questions/7084439/ora-12154-could-not-resolve-with-oracle-instant-client