加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

java.sql.SQLException: Io 异常: The Network Adapter could not

(2012-11-25 20:08:55)
标签:

杂谈

分类: Oracle

http://s9/mw690/9262dda2xcf50af38a668&690Io 异常: The Network Adapter could not" TITLE="java.sql.SQLException: Io 异常: The Network Adapter could not" />

按照视频上敲了一遍代码,不知道为什么总是这个问题,百度了下,

http://wenku.baidu.com/view/41dc05252f60ddccda38a091.htmlIo The Network Adapter could not establish the connection

 

把第二个和第三个都试过了。还是没有解决,又再第一个解决方案:

集中可能有错误的是如下这句:

ct = DriverManager.getConnection ("jdbc:oracle:thin:@127.0.0.1:1521:orclxy", "scott", "tiger");

决定把IP改下试试

然后查看ip:

WIN+R --> cmd -->ipconfig

http://s9/mw690/9262dda2xcf50d5633788&690Io 异常: The Network Adapter could not" TITLE="java.sql.SQLException: Io 异常: The Network Adapter could not" />

代码修改如下:

ct = DriverManager.getConnection
("jdbc:oracle:thin:@10.10.5.120:1521:orclxy", "scott", "tiger");

这样就好了http://www/uc/myshow/blog/misc/gif/E___6743EN00SIGG.gifIo 异常: The Network Adapter could not" TITLE="java.sql.SQLException: Io 异常: The Network Adapter could not" />

不知道为什么,菜鸟。视频上明明不是这样子的,待以后深入学习!!http://www/uc/myshow/blog/misc/gif/E___7397ZH00SIGG.gifIo 异常: The Network Adapter could not" TITLE="java.sql.SQLException: Io 异常: The Network Adapter could not" />

 

 

把上面那篇三个方式粘贴下来吧:

Io 异常: The Network Adapter could not establish the connection
这个异常的出现一般与数据库和你的PC的设置有关

这种异常的出现大致上有下面几种:


1。IP错误。
在设置URL时错误,例如:jdbc:oracle:thin:@192.168.0.36:1521:sharp
数据库服务器不正确:ping 服务器IP是否正确。不正确,将URL更改为正确
端口号错误:一般不会错误。
进行一下操作:在DOS上键入sqlplus,检查oracle是否开启
一却正常,执行下面第2步。

2。防火墙
如果机器上安装有放火墙,可能是服务器端口号屏蔽而造成的。关闭防火墙后,尝试重新连接。
仍然不行,执行第3步。

3。数据库监听未启动 修改PC上注册表中的ImagePath值。
我下面以现在主流的数据库ORACLE为例
重新手动启动数据库监听:
1:开始 → 运行→ 输入CMD→ 进入DOS命令提示界面
d:>lsnrctl
LSNRCTL> status
或者
LSNRCTL> start

以下是手动启动数据库的方法:
在运行处执行regedit进入注册表到
开始 →运行→ regedit
按下面路径
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\OracleOraHome90TNSListener
找到OracleOraHome90TNSListener(我用的是Oracle9i 其他的版本的应该是OracleOraHomexxxTNSListener)

http://s3/mw690/9262dda2xcf50ef51df52&690Io 异常: The Network Adapter could not" TITLE="java.sql.SQLException: Io 异常: The Network Adapter could not" />

找到之后你会发现ImagePath关键值不存在了,创建它:(存在的话,点击修改,修改方法在下文有介绍)
右键单击,弹出菜单选择新键(N)→字符串值(S)

http://s10/mw690/9262dda2xcf50ff550899&690Io 异常: The Network Adapter could not" TITLE="java.sql.SQLException: Io 异常: The Network Adapter could not" />

将其命名为ImagePath
选中ImagePath点右键,选中修改:

http://s12/mw690/9262dda2xcf51053b689b&690Io 异常: The Network Adapter could not" TITLE="java.sql.SQLException: Io 异常: The Network Adapter could not" />

在值中输入你的Oracle安装目录\ora90(其他版本对应的是oraxxx目录)\bin\tnslsnr
http://s6/mw690/9262dda2xcf5108a4d0e5&690Io 异常: The Network Adapter could not" TITLE="java.sql.SQLException: Io 异常: The Network Adapter could not" />
确定后退出注册表:
再在DOS命令下键入start
如果出现下面画面,恭喜你,监听器启动成功:

http://s9/mw690/9262dda2xcf511fcf0748&690Io 异常: The Network Adapter could not" TITLE="java.sql.SQLException: Io 异常: The Network Adapter could not" />
关闭DOS,启动你的程序进行测试,应该恢复正常了。
以上就是3中常见的引发The Network Adapter could not establish the connection 异常的原因

 

               《---END--》

 

刚才在看婚纱照,

都好漂亮哦。

看了下评论什么的,

都说成都的

*成都罗曼司摄影会馆*拍的不错,
看了下样品,
真的不错的样子呀,
都没拍过写真什么的,
人生失败呀,
等找到工作了,
也花个1000多拍个去,
以此来记住我花样的人生哦http://www/uc/myshow/blog/misc/gif/E___6724EN00SIGG.gifIo 异常: The Network Adapter could not" TITLE="java.sql.SQLException: Io 异常: The Network Adapter could not" />
加油喽http://www/uc/myshow/blog/misc/gif/E___7397ZH00SIGG.gifIo 异常: The Network Adapter could not" TITLE="java.sql.SQLException: Io 异常: The Network Adapter could not" />






后记:::

刚才查看Oracle有没有监听,

发现了状况http://www/uc/myshow/blog/misc/gif/E___6708EN00SIGG.gifIo 异常: The Network Adapter could not" TITLE="java.sql.SQLException: Io 异常: The Network Adapter could not" />

cmd -->netstat -an

如下图

http://s2/mw690/9262dda2xcf51cb6f6361&690Io 异常: The Network Adapter could not" TITLE="java.sql.SQLException: Io 异常: The Network Adapter could not" />

往下看,127.0.0.1

http://s6/mw690/9262dda2xcf51d4916e65&690Io 异常: The Network Adapter could not" TITLE="java.sql.SQLException: Io 异常: The Network Adapter could not" />
没有1521。

应该是这个样子的。http://www/uc/myshow/blog/misc/gif/E___7397ZH00SIGG.gifIo 异常: The Network Adapter could not" TITLE="java.sql.SQLException: Io 异常: The Network Adapter could not" />




 

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有