关于Toad连接DB2的sqlstate=08001错误

新装的centos6.3+db29.7,数据库导入完了的之后用Toad连接访问之的时候出错了。

DB2 Database Error: ERROR [08001] [IBM] SQL30081N A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS". Location where the error was detected: "10.20.51.155". Communication function detecting the error: "selectForConnectTimeout". Protocol specific error code(s): "0", "*", "*". SQLSTATE=08001 (Remembered answer: "OK". Enable)

查了好久,网上给了各种解释,其中有个人提到了可能与防火墙有关。

一开始我的做法很黄,就是把防火墙关了,连接下就能连上了。

$ service iptables stop

现在觉得需要添加规则,研究了下iptables相关命令。得出

[[email protected] ~]# iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 50000 -j ACCEPT

[[email protected] ~]# /etc/rc.d/init.d/iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
[[email protected] ~]# service iptables restart
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]

再次尝试用客户端连接,依然报错。查看下:

[[email protected] ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
5 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
6 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:50000

Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
num target prot opt source destination

原因猜测是优先顺序问题,在我们新规则之前有一个reject all,他禁止了对地发包的访问。

查询了下对应方法,发现我参数 iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 50000 -j ACCEPT

改成 iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 50000 -j ACCEPT,应该可以实现
*-A是插入规则到末尾,-I是插入到顶部

把刚刚的规则删除:

[[email protected] ~]# iptables -D INPUT 6
[[email protected] ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
5 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
num target prot opt source destination

删除成功,从新追加:

[[email protected]host ~]# iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 50000 -j ACCEPT
[[email protected] ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:50000
2 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
3 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
5 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
6 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
num target prot opt source destination

再次尝试连接,OK连上了。

这个时候要记得保存刚刚的更改。不然下次service iptables restart事件发生的话,那么此次设置无效,连接失败。

[[email protected] ~]# /etc/rc.d/init.d/iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
[[email protected] ~]# service iptables restart
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
[[email protected] ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:50000
2 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
3 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
5 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
6 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
num target prot opt source destination

到此结束。

时间: 2024-08-29 20:00:53

关于Toad连接DB2的sqlstate=08001错误的相关文章

一次DB2数据库连接失败(SQLSTATE=08001)的解决方法

有一次,在使用DbVisualizer工具连接自己linux虚拟机上的DB2数据库时,报如下错误: Product: DbVisualizer Pro 9.1 Build: #2050 (2013/09/08 11:03) Java VM: Java HotSpot(TM) 64-Bit Server VM Java Version: 1.6.0_43 Java Vendor: Sun Microsystems Inc. OS Name: Windows 7 OS Arch: amd64 OS

急!JDBC问题,发生通信错误。错误位置:Reply.fill()。消息:数据不足。 ERRORCODE=-4499, SQLSTATE=08001

代码如下:Class.forName("com.ibm.db2.jcc.DB2Driver");Connection conn = DriverManager.getConnection("jdbc:db2://localhost:50000/sample","db2admin","12345678"); 第二句时就报这个错误:com.ibm.db2.jcc.am.yn: [jcc][t4][2030][11211][3.57

db2 连接报错connect。 ERRORCODE=-4499, SQLSTATE=08001(转载)

在使用data studio连接远程DB2数据库时报错如下: [jcc][Thread:main][[email protected]] java.sql.SQLException [jcc][Thread:main][[email protected]] SQL state  = 08001 [jcc][Thread:main][[email protected]] Error code = -4499 [jcc][Thread:main][[email protected]] Message

Sqoop从DB2导出数据出错:ERRORCODE=-4499, SQLSTATE=08001

Sqoop执行命令: ./sqoop import --connect "jdbc:db2://10.105.4.55:50001/SCCRM55" --username db2inst1 --password db2opr2010 --table WF_4G_BILLDETAIL_NEW_20140717 --fetch-size 1000 -m 1 --target-dir /ext/ods/ODS_RPT_DAY_DET/20140717_1 --fields-terminate

Navicat 远程连接SQL Server 2014 Express 报08001错误

场景:Navicat 远程连接SQL Server 2014 Express 报08001错误,经查验防火墙端口1434,1433已经打开 过程:1. 一开始觉得是连接名称问题,使用IP地址或者主机名进行连接,然后更换为IP地址\命名实例方式,使用后者较好 2. 更换连接字符串后仍然报错08001,尝试关闭防火墙,连接成功,说明问题出现在端口上 3. 使用netstat –ano命令查看,发现此命令太鸡肋,上网查找工具,发现CurrPorts工具,甚好,发一个截图.该软件可以清晰的看到各种连接信

连接db2数据库出现No buffer space available (maximum connections reached?)

Caused by: javax.naming.NamingException: [jcc][t4][2043][11550][3.57.82] 异常 java.net.SocketException:打开端口 50,000 上服务器 localhost/127.0.0.1 的套接字时出错,消息为:No buffer space available (maximum connections reached?): connect. ERRORCODE=-4499, SQLSTATE=08001 数

R 连接DB2数据库

1.odbc文件下载 http://dasapp.oregon.gov/datamart/files/IBM_DB2_9.7_Run_Time_client_Notes.pdf 打开:http://dasapp.oregon.gov/datamart/ 下载驱动,并安装. 配置odbc,刚开始按教程,在odbc里并没有找到db2 driver 后面在C:\Windows\SysWOW64 下搜索ODBC,找到这个: 打开后按教程配置即可. 配置还参考:http://xujingli88.blog

c#连接db2数据库

.net项目要连接db2数据库,是要安装客户端的,否则是连接不上的: 若出现“未在本地计算机上注册‘ibmdadb2’提供程序” 解决办法: 1.先找到安装后的ibmdadb2.dll文件复制到c:\windows\system32或syswow64下 然后在运行中输入 regsvr32 ibmdadb2.dll,注册成功 2.要是在64位系统上安装的是32位的db2数据库,则在vs2010调试平台上改成x86 ,否则还是会出现这个错误

远程连接db2数据库

在db2数据库中,需要理解catalog(编目)这个概念,理解前先说下db2数据库的体系结构:由系统(节点)也就是主机,下面是实例,实例下面是数据库,然后是表空间,再是数据库对象.现在假设你有一个数据库服务器建立在MDMNODE1 的机器上,你有一个客户端在windows.linux或任何平台上,你现在想建立一个客户端到服务器端的连接,具体步骤如下: <第一步> 要在客户端的机器上能够把远程的服务器能够识别出来,怎么做? 在DB2使用编目(catalog)方式,具体来说就是通过编目把远程的服务