0
votes

I have tried to connect to DB2/AS400 remote database with db2cli odbc module and odbc_connect but returns the next error:

Execution failed: [unixODBC][IBM][CLI Driver] 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.10.100.5". Communication function detecting the error: "recv". Protocol specific error code(s): "", "", "0". SQLSTATE=08001

This is my PHP code:

<?php

$database = 'xxxx';
$user = 'xxxx';
$password = 'xxxx';
$hostname = '10.10.100.5';
$port = '55000';
$driver = 'DB2';

$conn_string = "DRIVER={$driver};DATABASE=$database;HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP;UID=$user;PWD=$password;";

if (!$db = odbc_connect ($conn_string, $user, $password)) {
     print("Execution failed:\n");
}

else echo 'Success!';


odbc_close($db);

Help me please!!

1
The configuration is not correct. Try to do: telnet 10.10.100.5 55000AngocA
Did you install the IBM i Access software and verify that it works?mustaccio
Does the connection fail right away or does it fail later on?GeekyDaddy
Here is an article from IBM regarding that error. www-01.ibm.com/support/docview.wss?uid=swg21673820GeekyDaddy

1 Answers

0
votes

I am not familiar with AS400, but on Linux/UNIX this error happens when the TCP/IP communication has not been set properly at the server side. There are two things I would check (on a Linux/UNIX server, not sure about the AS400 equivalents):

  1. netstat -na
  2. db2set DB2COMM=TCPIP

The first command will return the list of open TCP/IP listeners. Your port 55000 should be on the list. If it is not, it means the server is not open for communication.

The second part enables TCP/IP communication in DB2. Note that there are dependencies on /etc/services and the SVCENAME DBM CFG parameter. The server must be restart for DB2COMM to take effect. When enabled properly, DB2 should start listening at the configured port.

If none of this helps, then it is possible that a firewall is blocking access to the DB2 server.

Again, I apologize if this reply does not apply to AS400.