Workaround for one DB2 database connection failure (SQLSTATE=08001)

Source: Internet
Author: User
Tags db2 db2 port iptables dbvisualizer

Once, when using the Dbvisualizer tool to connect the DB2 database on its own Linux virtual machine, the following error was reported:

Product:dbvisualizer Pro 9.1Build: #2050 (2013/09/08 11:03) Java Vm:java HotSpot (TM)64-Bit Server Vmjava Version:1.6. 0_43java Vendor:sun Microsystems Inc.os name:windows7OS arch:amd64os Version:6.1An error occurred whileestablishing the Connection:long Message:[jcc][t4][ 2043] [11550] [4.15.82] Exception java.net.ConnectException: An error occurred when opening a socket on port 50,000 for server/192.168.17.88, with the message: Connection timed out:connect. errorcode=-4499, sqlstate=08001Details:Type:com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException Error Code:-4499SQL State:08001

On Baidu search "DB2 sqlstate=08001", find the following information:

The general cause of this problem: 1.db2comm=TCPIP2. Database Failure 3. The port number is disabled solution:1. See if the port number is configured correctly, Take a look at the configuration parameters Svcename is consistent with the DB2 port number configured in the Services file, and Windows generally uses the 50000,unix/linux 60000. 2-AllView the configuration of the Database manager, view Svcename (specifically the TCPIP Protocol) DB2 get dbm cfg view  /etc/services, There is no port corresponding to the above svcename, for example: DB2CDB2 50000/tcp

To view the DB2 database port settings on my Linux virtual machine:

[Email protected] ~]# Cat/etc/services |  50000/tcp

There is no problem with port settings, look at firewall settings:

[[Email protected] ~]# service iptables status±í¸ñ£ºfilterchain INPUT (policy ACCEPT) num target prot opt source Destina tion1 ACCEPT All--0.0.0.0/0 0.0.0.0/0State related,established2 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 Accept TCP--           0.0.0.0/0 0.0.0.0/0 State NEW TCP dpt:80 6 ACCEPT TCP--0.0.0.0/0 0.0.0.0/0 State new TCP dpt:81 7 ACCEPT TCP--0.0.0.0/0 0.0.0.0/0 State New TCP dpt:8080 8 A            Ccept TCP--0.0.0.0/0 0.0.0.0/0 State NEW TCP dpt:8081 9 ACCEPT TCP--0.0.0.0/0 0.0.0.0/0 state NEW TCP dpt:8001 ACCEPT TCP--0.0.0.0/0 0.0.0.0/0 State NEW TCP dpt:8002 REJECT All--0.0.0.0/0 0.0.0.0/0 reject- withicmp-host-prohibited Chain FORWARD (policy ACCEPT) num Target prot opt source destination1 REJECT All--0.0.0.0/0 0.0.0.0/0 reject- withicmp-host-prohibited Chain OUTPUT (policy ACCEPT) num Target prot opt source destination [[Email Prote CTED]~]#

The original firewall did not turn on port 50000. Edit the file and add a record to it:

One-to-one ACCEPT TCP--0.0.0.0/0 0.0.0.0/0 state NEW TCP dpt:50000

After adding, restart the iptables settings (be sure to restart, otherwise not take effect) and view the firewall port settings information again (note the Red Flag section):

[[Email protected] ~]# service iptables Restart purge firewall rule: [OK] set chains to ACCEPT policy: Filter                                   [ OK ] uninstalling iiptables module [ OK ] Apply iptables firewall rule [ OK ] [[Email protected]~]# service iptables status±í¸ñ£ºfilterchain INPUT (policy ACCEPT) num target prot opt source Destina tion1 ACCEPT All--0.0.0.0/0 0.0.0.0/0State related,established2 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 Accept TCP--           0.0.0.0/0 0.0.0.0/0 State NEW TCP dpt:80 6 ACCEPT TCP--0.0.0.0/0 0.0.0.0/0 State new TCP dpt:81 7 ACCEPT TCP--0.0.0.0/0 0.0.0.0/0 State New TCP dpt:8080 8 A            Ccept TCP--0.0.0.0/0 0.0.0.0/0 State NEW TCP dpt:8081 9 ACCEPT TCP--0.0.0.0/0 0.0.0.0/0 state NEW TCP dpt:8001 ACCEPT TCP--0.0.0.0/0 0.0.0.0/0 State NEW TCP dpt:8002One-to-one  ACCEPT TCP--0.0.0.0/0 0.0.0.0/0 State NEW TCP dpt:50000 REJECT All--0.0.0.0/0 0.0.0.0/0 reject- withicmp-host-prohibited Chain FORWARD (policy ACCEPT) num Target prot opt source destination1 REJECT All--0.0.0.0/0 0.0.0.0/0 reject- withicmp-host-prohibited Chain OUTPUT (policy ACCEPT) num Target prot opt source destination [[Email Prote CTED]~]#

Use the Dbvisualizer tool again to connect to the database, success!

Workaround for one DB2 database connection failure (SQLSTATE=08001)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.