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

有以下四个原因:

1、oracle配置

listener.ora 和tnsnames.ora 文件里面查看是否配置正确

2、IP错误

在设置URL时错误,例如:jdbc:oracle:thin:@192.168.0.36:1521:sharp

3、防火墙

机器上安装有其他放火墙,可能是服务器端口号屏蔽而造成的。关闭防火墙后,尝试重新连接。

4、数据库监听未启动

1.su oracle

然后启动监听器

1.lsnrctl start 

会看到启动成功的界面;

1.lsnrctl stop 

停止监听器命令.

1.lsnrctl status 

查看监听器命令.

oracle数据库的安全包含两部分:

1.一部分是os的安全

2.网络的安全

3.oracle软件本身的安全

os的安全依赖相应的操作系统及管理员的技术水平,我们这里只谈谈oracle的安全

我了解的oracle软件的安全包含

1.更改oracle的默认监听端口号

2.给监听器加密码

3.oracle控制ip的连接

下面将针对这三个方面测试学习

---------oracle默认监听端口更改--------------

1. 更改oracle的默认监听端口号

修改端口号的整体步骤

1.1 。 查看当前监听的状态

1.2 。 停止监听

1.3 。 修改监听文件的端口号

1.4 。 修改初始化参数local_listener

1.5 .  重启监听器

1.6 。 修改完毕,使用新端口登录测试

实践步骤:

1.1 。 查看当前监听的状态

C:/Documents and Settings/skate_db>lsnrctl status

LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 19-7月 -2008 12:1

1:19

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

正在连接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))

LISTENER 的 STATUS

------------------------

别名                      LISTENER

版本                      TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Produ

ction

启动日期                  19-7月 -2008 11:47:59

正常运行时间              0 天 0 小时 23 分 19 秒

跟踪级别                  off

安全性                    ON: Password or Local OS Authentication

SNMP                      OFF

监听程序参数文件          E:/oracle/product/10.2.0/db_3/network/admin/listener.o

ra

监听程序日志文件          E:/oracle/product/10.2.0/db_3/network/log/listener.log

监听端点概要...

(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=//./pipe/EXTPROC1ipc)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=skate)(PORT=1522)))

服务摘要..

服务 "PLSExtProc" 包含 1 个例程。

例程 "PLSExtProc", 状态 UNKNOWN, 包含此服务的 1 个处理程序...

服务 "orcl" 包含 1 个例程。

例程 "orcl", 状态 READY, 包含此服务的 1 个处理程序...

服务 "orclXDB" 包含 1 个例程。

例程 "orcl", 状态 READY, 包含此服务的 1 个处理程序...

服务 "orcl_XPT" 包含 1 个例程。

例程 "orcl", 状态 READY, 包含此服务的 1 个处理程序...

命令执行成功

1.2 。 停止监听

C:/Documents and Settings/skate_db>lsnrctl stop

LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 19-7月 -2008 13:1

6:15

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

正在连接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))

命令执行成功

1.3 。 修改监听文件的端口号,用于网络连接

把端口号修改为1523

# listener.ora Network Configuration File: E:/oracle/product/10.2.0/db_3/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_3)

(PROGRAM = extproc)

)

)

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))

(ADDRESS = (PROTOCOL = TCP)(HOST = skate)(PORT = 1523))

)

)

#----ADDED BY TNSLSNR 12-7月 -2008 13:26:50---

PASSWORDS_LISTENER = 3650F1EB3C37ABD9

#---------------------------------------------

1.4 。 修改初始化参数local_listener  ,用于本地连接

C:/Documents and Settings/skate_db>sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on 星期六 7月 19 13:24:02 2008

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

连接到:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

SQL> show parameter local_listener

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

local_listener                       string      (address=(protocol=tcp)(host=s

kate)(port=1522))

SQL> alter system set local_listener="(address=(protocol=tcp)(host=skate)(port=1

523))";

系统已更改。

1.5 .  重启监听器

C:/Documents and Settings/skate_db>lsnrctl start

LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 19-7月 -2008 13:2

7:44

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

启动tnslsnr: 请稍候...

TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Production

系统参数文件为E:/oracle/product/10.2.0/db_3/network/admin/listener.ora

写入E:/oracle/product/10.2.0/db_3/network/log/listener.log的日志信息

监听: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=//./pipe/EXTPROC1ipc)))

监听: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=skate)(PORT=1523)))

正在连接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))

LISTENER 的 STATUS

------------------------

别名                      LISTENER

版本                      TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Produ

ction

启动日期                  19-7月 -2008 13:27:47

正常运行时间              0 天 0 小时 0 分 3 秒

跟踪级别                  off

安全性                    ON: Password or Local OS Authentication

SNMP                      OFF

监听程序参数文件          E:/oracle/product/10.2.0/db_3/network/admin/listener.o

ra

监听程序日志文件          E:/oracle/product/10.2.0/db_3/network/log/listener.log

监听端点概要...

(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=//./pipe/EXTPROC1ipc)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=skate)(PORT=1523)))

服务摘要..

服务 "PLSExtProc" 包含 1 个例程。

例程 "PLSExtProc", 状态 UNKNOWN, 包含此服务的 1 个处理程序...

命令执行成功

1.6 。 修改完毕,使用新端口登录测试

1.6.1。 检查监听端口是否改变

C:/Documents and Settings/skate_db>netstat -an | find "1523"

TCP    0.0.0.0:1523           0.0.0.0:0              LISTENING

TCP    192.168.0.103:1523     192.168.0.103:2389     ESTABLISHED

TCP    192.168.0.103:2389     192.168.0.103:1523     ESTABLISHED

1.6.2。 查看监听器的状态

C:/Documents and Settings/skate_db>lsnrctl status

LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 19-7月 -2008 13:2

8:56

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

正在连接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))

LISTENER 的 STATUS

------------------------

别名                      LISTENER

版本                      TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Produ

ction

启动日期                  19-7月 -2008 13:27:47

正常运行时间              0 天 0 小时 1 分 10 秒

跟踪级别                  off

安全性                    ON: Password or Local OS Authentication

SNMP                      OFF

监听程序参数文件          E:/oracle/product/10.2.0/db_3/network/admin/listener.o

ra

监听程序日志文件          E:/oracle/product/10.2.0/db_3/network/log/listener.log

监听端点概要...

(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=//./pipe/EXTPROC1ipc)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=skate)(PORT=1523)))

服务摘要..

服务 "PLSExtProc" 包含 1 个例程。

例程 "PLSExtProc", 状态 UNKNOWN, 包含此服务的 1 个处理程序...

服务 "orcl" 包含 1 个例程。

例程 "orcl", 状态 READY, 包含此服务的 1 个处理程序...

服务 "orclXDB" 包含 1 个例程。

例程 "orcl", 状态 READY, 包含此服务的 1 个处理程序...

服务 "orcl_XPT" 包含 1 个例程。

例程 "orcl", 状态 READY, 包含此服务的 1 个处理程序...

命令执行成功

1.6.3 。使用新端口号(1523)登录测试一下

C:/Documents and Settings/skate_db>sqlplus

SQL*Plus: Release 10.2.0.1.0 - Production on 星期六 7月 19 13:32:15 2008

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

请输入用户名:  sys/oracle@skate:1523/orcl as sysdba

连接到:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

SQL>

SQL> select * from v$version;

BANNER

----------------------------------------------------------------

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod

PL/SQL Release 10.2.0.1.0 - Production

CORE    10.2.0.1.0      Production

TNS for 32-bit Windows: Version 10.2.0.1.0 - Production

NLSRTL Version 10.2.0.1.0 - Production

SQL> select open_mode from v$database;

OPEN_MODE

----------

READ WRITE

SQL>

注意:当修改了oracle默认监听端口后,用tnsping会出错的,因为这个时候,oracle会

读tnsnames。ora这个文件,而这个文件的端口号没有更改,只要更改下这里对应的

端口号就ok。

eg:

C:/Documents and Settings/skate_db>tnsping orcl

TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 19-7月 -

2008 17:11:05

Copyright (c) 1997, 2005, Oracle.  All rights reserved.

已使用的参数文件:

E:/oracle/product/10.2.0/db_3/network/admin/sqlnet.ora

已使用 TNSNAMES 适配器来解析别名

Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = skate)(P

ORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))

TNS-12541: TNS: 无监听程序

在这里可以看到,oracle仍然用端口1521,我们更改下tnsnames.ora的端口号,就ok了。

# tnsnames.ora Network Configuration File: E:/oracle/product/10.2.0/db_3/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

ORCL =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = skate)(PORT = 1523))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = orcl)

)

)

EXTPROC_CONNECTION_DATA =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))

)

(CONNECT_DATA =

(SID = PLSExtProc)

(PRESENTATION = RO)

)

)

重启监听器,在tnsping

C:/Documents and Settings/skate_db>tnsping orcl

TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 19-7月 -

2008 17:22:00

Copyright (c) 1997, 2005, Oracle.  All rights reserved.

已使用的参数文件:

E:/oracle/product/10.2.0/db_3/network/admin/sqlnet.ora

已使用 TNSNAMES 适配器来解析别名

Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = skate)(P

ORT = 1523)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))

OK (50 毫秒)

---------oracle默认监听端口更改--------------

××××××××××××××××××××××××××oracle控制ip的连接××××××××××××××××××××××××

2 .oracle控制ip的连接(我们也可以用数据库触发器记录用户的登录情况,但是不能记录dba权限的用户)

单纯的设定允许的IP 和 禁止的IP,在oracle9i以前有文档说增加或修改protocol.ora文件,

在9i及以后版本中真正起作用的是sqlnet.ora文件,我们修改sqlnet.ora其实是最好最快的方法

sqlnet.ora文件的功能:

1. Specify the client domain to append to unqualified names

2. Prioritize naming methods

3. Enable logging and tracing features

4. Route connections through specific processes

5. Configure parameters for external naming

6. Configure Oracle Advanced Security

7. Use protocol-specific parameters to restrict access to the database

我在这里用的就是第7个功能

在sqlnet.ora中增加如下部分

-----------------------------

tcp.validnode_checking=yes 



#允许访问的IP

tcp.invited_nodes=(ip1,ip2……) 



#禁止访问的IP

tcp.excluded_nodes=(ip1,ip2……)



之后重新启动监听器即可

eg:

# sqlnet.ora Network Configuration File: E:/oracle/product/10.2.0/db_3/network/admin/sqlnet.ora

# Generated by Oracle configuration tools.

# This file is actually generated by netca. But if customers choose to

# install "Software Only", this file wont exist and without the native

# authentication, they will not be able to connect to the database on NT.

SQLNET.AUTHENTICATION_SERVICES= (NTS)

NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

#skate modify

tcp.validnode_checking=yes

tcp.invited_nodes=(192.168.0.103)

tcp.excluded_nodes=(192.168.0.10)

需要注意的问题:

1、 需要设置参数为YES,这样才能激活。

2、 建议设置允许访问的IP,因为IP地址有可能被随意修改,就不能起到自己的目的。

3、 TCP当参数TCP.INVITED_NODES和TCP.EXCLUDED_NODES设置的地址相同的时候将覆盖TCP.EXCLUDED_NODES设置。

4、 需要重启监听器才能生效。

5、 这个方式只是适合TCP协议。

6、 这个配置适用于9i以上版本。在9i之前的版本使用文件protocol.ora。

7、 在服务器上直接连接数据库不受影响。

8、 这种限制方式事通过监听器来限制的。

9、 这个限制只是针对IP检测,对于用户名检测事不支持的。

数据库连接报错之IO异常(The Network Adapter could not establish the connection)的更多相关文章

  1. Oracle连接报错之IO异常(The Network Adapter could not establish the connection)

    简单介绍:自己封装oracle jdbc的一些常用功能jar包,自己本机玩没啥问题,给别人玩儿,发现总是抛异常 IO异常(The Network Adapter could not establish ...

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

    新接触一个项目,导入源码,在本地启动的时候后台报了一个错误: Could not discover the dialect to use. java.sql.SQLException: Io 异常: ...

  3. oracle:程序后台提示Io异常: The Network Adapter could not establish the connection)

    今天要用tomcat部署一个系统,windows环境下,oracle和程序在一台机器上. 在配置jndi时,直接写成 jdbc:oracle:thin:@127.0.0.1:1521:orcl.启动程 ...

  4. Io 异常: The Network Adapter could not establish the connection解决方案

    Io 异常: The Network Adapter could not establish the connection解决方案 2016年06月04日 13:30:21 阅读数:46589 Io ...

  5. Io 异常: The Network Adapter could not establish the connection 解决方法

    1.IP错误: 在设置URL时错误,例如:jdbc:oracle:thin:@192.168.1.80:1521:orcl 数据库服务器是否正确:ping 服务器IP是否通畅.ping不通则将URL更 ...

  6. [Oracle] Io Error: The Network Adapter could not establish the connection 解决方案

    Io 异常: The Network Adapter could not establish the connection这个异常的出现一般与数据库和你的PC的设置有关 这种异常的出现大致上有下面几种 ...

  7. sqldeveloper建立新的连接是出现Status : Failure -Test failed: IO Error: The Network Adapter could not establish the connection

    Status : Failure -Test failed: IO Error: The Network Adapter could not establish the connection解决办法: ...

  8. The Network Adapter could not establish the connection问题研究

    最近一个项目会报上述错误,但也不是经常发生,所以很难跟踪,影响不是很大,但每次看到日志中这个错误就会不舒服,还是要想办法解决才是. 错误提示信息很明确是网络适配器不能创建连接. 查了很多资料,并且Or ...

  9. 数据库 The Network Adapter could not establish the connection解决方案

    连接数据库 注意 url ip地址换的时候 oracle 里的listener.ora thnsnames.ora也要随之变化 重启数据库 不然可能会报出 java.sql.SQLException: ...

随机推荐

  1. Array.asList()注意

    api: public static <T> List<T> asList(T... a) 返回一个受指定数组支持的固定大小的列表.(对返回列表的更改会“直接写”到数组.)此方 ...

  2. 等方案及设备提供商 有需要的可以联系QQ561454825,电话:13779953060,我们提供最专业的无线WIFI认证系统及根据您的需要修改软件

    WayOs智能路由.EasyRadius云计费.POE远程供电.WIFI城中村方案.EPON实现FTTB+LAN城中村方案. 等方案及设备提供商 有需要的可以联系QQ561454825,电话:,我们提 ...

  3. [LeetCode#266] Palindrome Permutation

    Problem: Given a string, determine if a permutation of the string could form a palindrome. For examp ...

  4. HDU-4972 A simple dynamic programming problem

    http://acm.hdu.edu.cn/showproblem.php?pid=4972 ++和+1还是有区别的,不可大意. A simple dynamic programming proble ...

  5. Perfect Squares——Leetcode

    Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 1 ...

  6. 工作总结之动画与VR

    一.Unity5的动画新特性: 1.animator controller默认就包含Any State.Entry.Exit三个状态 2.animator可以给每个动画片段添加脚本,该脚本继承 Sta ...

  7. UVA 11796 Dog Distance(向量)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=31962 [代码] #include<cstdio> # ...

  8. 4G来临 IT业转型之路当在不远

    摘 要:4G商用未启,品牌营销争夺已经展开.目前,除了中国移动推出全新4G品牌“andM”之外,中国电信和中国联通均选择继续沿用3G的品牌. 4G商用未启,品牌营销争夺已经展开.12月10日,中国电信 ...

  9. UIView与CALayer的区别,很详细

    研 究Core Animation已经有段时间了,关于Core Animation,网上没什么好的介绍.苹果网站上有篇专门的总结性介绍,但是似乎原理性的东西不多,看得人云山雾罩,感觉,写那篇东西的人, ...

  10. python小程序——购物

    流程图  代码程序 saving = int(input('请输入你的工资:'))shopping = [['iphone',5800],['mx6',2000],['pythonbook',80], ...