0

I'm trying to use ibm_db2 extension to access iSeries DB2 database.

This is the testcode (taken from here)

<?php
$database = 'ALI452BFAL'; //library
$user = 'STN452';
$password = '**********';
$hostname = 'myserverip';
$port = 50000;

$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;" .
  "HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP;UID=$user;PWD=$password;";
$conn = db2_connect($conn_string, '', '');

if ($conn) {
    print "ok";
    db2_close($conn);
}
else {
    echo db2_conn_error() . '<br>' . db2_conn_errormsg();
}
?>

I have installed a very basic package containing the db2 driver and added this as an extension.
(IBM Data Server Driver for ODBC, CLI, and .NET.msi)

This is my result:

08001 [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.0.120". Communication function detecting the error: "connect". Protocol specific error code(s): "10061", "", "". SQLSTATE=08001 SQLCODE=-30081

Anybody tried this before??

grmbl
  • 155
  • 1
  • 9

1 Answers1

0

The port number you are using is incorrect – iSeries servers use port 446, not port 50000.

However, in order to use the IBM Data Server Driver for ODBC, CLI and .Net to access your iSeries server, you must have a license for the IBM product called DB2 Connect.

You do not need to use DB2 Connect, you can use the IBM i Access for Windows product, which provides an ODBC driver to connect directly to your iSeries server.

Ian Bjorhovde
  • 481
  • 2
  • 2
  • Hi, I looked for the default port but couldn't find anything. So thank you for pointing me in the right direction. I don't know if we have a license for DB2 Connect. How can I check this? I know I could connect using ODBC but I would like to use a native driver for increased compatibility/functionality. – grmbl Nov 14 '13 at 07:58
  • Nevermind Ian, I changed the port to 446 (+ the database, I gave a Library file) and now I get this error which confirms we are not licensed to use DB2 Connect... `[IBM][CLI Driver] SQL8002N An attempt to connect to a host failed due to a missing DB2 Connect product or invalid license. SQLSTATE=42968 SQLCODE=-8002` But do I need a client license or server license? – grmbl Nov 14 '13 at 08:16