报错:java.sql.SQLException: Listener refused the connection with the following error:ORA-12505, TNS:listener does not currently know of SID given in connect descriptorThe Connection descriptor used by the client was:localhost:1521:orcl
解决方案:
找到oracle中的app\oracle\product\10.2.0\server\NETWORK\ADMIN\tnsname.ora
tnsname.ora文件
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = GEMPTC)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
注意(1)书写oracle的url的时候需要将HOST = GEMPTC和 jdbc:oracle:thin:@GEMPTC:1521:XE匹配
SERVICE_NAME = XE 与 dbc:oracle:thin:@GEMPTC:1521:XE 匹配
(2)HOST = GEMPTC为什么是GEMPTC呢?
GEMPTC代表的是你的主机名,每个人的主机名都是不同的,所以你需要自己查询。查询语法如下:
select HOST_NAME from v$instance
希望对大家有所帮助!