想连接一个本机的数据库,问tns文件要怎么写?
mldn =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = mldn)
)
)
本地的数据库叫mldn,上述信息是我照着改的,没成功。问问大侠们,相应的参数要怎么改!
------最佳解决方案--------------------#你所要连接的时候输入得TNSNAME
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
#下面是这个TNSNAME对应的主机,端口,协议
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
)
(CONNECT_DATA =
#使用专用服务器模式去连接需要跟服务器的模式匹配,如果没有就根据服务器的模式自动调节
(SERVER = DEDICATED)
#对应service_name,SQLPLUS>;show parameter service_name; 进行查看
(SERVICE_NAME = orcl)
)
)
#下面这个类似
SALES =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.188.219)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = sales)
)
)
给你参考哈。~
------其他解决方案--------------------本机有监听吗?
有的话自己照着监听的host写tnsnames.ora里的host
------其他解决方案--------------------
把错误帖上来,另外,你的HOST = localhost和SERVICE_NAME = mldn确定是对的吗?
------其他解决方案--------------------监听文档:
# listener.ora Network Configuration File: d:\oracle\product\10.1.0\db_2\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = d:\oracle\product\10.1.0\db_2)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = PC-201206131517)(PORT = 1521))
)
)