`
regedit_123
  • 浏览: 324824 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
文章分类
社区版块
存档分类
最新评论

Io 异常: The Network Adapter could not establish the connection

阅读更多

Io 异常: The Network Adapter could not establish the connection

 

确认oracle的两个service服务是否打开了???

OracleOraDb10g_home1TNSListener

OracleServiceORCL

 

 

java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
localhost:1521:ORCL

 

一次连接数据库怎么也连接不上,查了多方面资料,终于找到答案,总结

首先应该保证数据库的服务启动
在myeclipse的数据库视图中点 右键->new 弹出database driver的窗口,
Driver template选择oracle(thin driver),
Driver name 输入oracle  
connection URL=jdbc:oracle:thin:@localhost:1521:oracle 注意localhost:1521:oracle中的oracle是数据库得sid 换成你自己数据库的sid 就可以
username:登陆数据库具有system权限的用户名
password:登陆数据库具有system权限的密码
点击add jar 选择ojdbc14.jar的存放位置,没有得可以到百度下一个叫ojdbc14.jar的文件。
点击test driver 到此成功配置。

关于启动数据库后提示ora-12505的解决方法:
"listener does not currently know of SID given in connect descriptor "

第一种可能
是配置得数据库sid 名不正确localhost:1521:oracle 即红字部分不是你本机得sid ,那么如何查看本机得sid 呢?

用如下命令 SELECT   NAME   FROM   v$database ;应该是以sysdba的身份进行的操作,在sqlplus中执行就可以看到,把红字部分换成查询出来的sid 就可以。


第二种可能
发现sid 配置没有错误,但是还是报错,那可能就是oracle得监听配置出了问题,需要检查listener .ora文件,用记事本打开,
正确配置如下:
# listener .ora Network Configuration File: e:\oracle\product\10.2.0\db_1\network\admin\listener .ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = e:\oracle\product\10.2.0\db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = oracle )
(ORACLE_HOME = e:\oracle\product\10.2.0\db_1)
(SID_NAME = oracle )
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
)
红字部分改成oracle 创建时候的sid 保存退出。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics