问题:TNS:无法解析指定的连接标识符
ORA-12154: TNS:could not resolve the connect identifier specified
原因:
连接到数据库或其它服务需要使用一个连接符(identifier),指定连接标识符不能解析到使用一种配置命名方法的连接描述符。比如:如果这种类型的连接标识符使用的是网络服务名,这个网络服务名不能在名称库中被找到,也许这个库不在本地,或者不可达。
Cause: A connection to a database or other service was requested using a connect identifier, and the connect identifier specified could not be resolved into a connect descriptor using one of the naming methods configured. For example, if the type of connect identifier used was a net service name then the net service name could not be found in a naming method repository, or the repository could not be located or reached.
方法:
如果你使用本地名称(TNSNAMES.ORA 文件)
(- If you are using local naming (TNSNAMES.ORA file):)
确认在"TNSNAMES" 是Oracle Net profile (SQLNET.ORA)的NAMES.DIRECTORY_PATH parameter参数中的一个值。
(- Make sure that "TNSNAMES" is listed as one of the values of the NAMES.DIRECTORY_PATH parameter in the Oracle Net profile (SQLNET.ORA))
检查TNSNAMES.ORA文件是否存在,它所在的目录是否正确和可访问。
(- Verify that a TNSNAMES.ORA file exists and is in the proper directory and is accessible.)
检查网络服务名,作为连接标识符在tnsnames.ora文件中存在。
(- Check that the net service name used as the connect identifier exists in the TNSNAMES.ORA file.)
确认TNSNAMES.ORA文件中没有语法错误。找出不匹配的括号或错误的字符。TNSNAMES.ORA文件中存在错误可能导致其不能使用。
(- Make sure there are no syntax errors anywhere in the TNSNAMES.ORA file. Look for unmatched parentheses or stray characters. Errors in a TNSNAMES.ORA file may make it unusable.)
几个建议:
1)假设是客户机服务器方式,你的客户机首先要能够ping通服务器。
2)客户机上正确安装了Oracle客户端软件。
3)服务器上的监听器配置正确,假设自己手工写TNSNAMES.ORA文件没有经验,建议你使用Netca工具生成监听器。
4)使用命令tnsping 服务名,测试客户端到服务器的通信,测试结果告诉你是否连通,服务器的主机地址(IP)或名称,服务名等内容。
5)连接命令格式:sqlplus 用户名/密码@服务器地址(IP)/服务名。假设是管理员,需要在后面加上as 角色名。
6)假设是一般用户,这个用户应该具有一定的权限,刚创建的用户假设没有授予权限也是连不通的。 |