DB2 PHP connection issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Harmony504
    New Member
    • Oct 2007
    • 14

    DB2 PHP connection issue

    I am trying to connect to our DB2 DB with PHP using ADOdb. Below is my environment.

    Windows XP
    PHP 5.2.5
    DB2 Run-Time Client 8.2
    IIS

    I connect with the following code:
    [PHP]
    include('adodb/adodb.inc.php') ;
    $db = ADONewConnectio n('db2');

    $dsn = "driver={IB M db2 odbc DRIVER};Databas e=$DBName;hostn ame=$Host;port= $Port;protocol= TCPIP;uid=$User ;pwd=$Password" ;
    if ($db->Connect($dsn )) {
    echo "It worked";
    } else {
    echo "***didn't work db->Connect(dsn)<b r>";
    echo 'SQLSTATE: '.$db->ErrorNo()."<br >";
    echo 'Message: '.$db->ErrorMsg()."<b r><br>";
    }
    [/PHP]

    I get the following error:
    Code:
    ***didn't work db->Connect(dsn)
    SQLSTATE: 42968
    Message: [IBM][CLI Driver] SQL8002N Connect processing failed; a valid product license was not found. SQLSTATE=42968 SQLCODE=-8002
    I know I am using the correct iSeries port, the correct DB name, and a fully licensed server. Has anyone ever seen this error?
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Are you able to connect to the database from the command line?
    If you installed your license key correctly then you might need to contact your IBM representative.

    Comment

    • Harmony504
      New Member
      • Oct 2007
      • 14

      #3
      I GOT IT!

      You need to install iSeries Client Access on your PHP server to get the correct drivers you need. I did a custom install and selected to install the Required Programs and Data Access including Data Transfer, ODBC, and OLE DB Provider.

      Then I connected as below.
      [PHP]
      include('adodb/adodb.inc.php') ;
      $db = ADONewConnectio n('odbc');
      $dsn = "DRIVER={iSerie s Access ODBC Driver};SYSTEM= $Host;DATABASE= $DBName;PROTOCO L=TCPIP;PORT=$P ort;";
      if ($db->Connect($dsn,$ User,$Password) ){
      echo "It worked";
      $sql = "SELECT table_name, table_type, table_schema, system_table_na me FROM qsys2.systables ";
      $rs = $db->Execute($sql );
      if (!$rs) echo "<p>no records</p>";
      else {
      $result = $rs->GetArray();
      echo "<pre>";
      print_r($result );
      echo "</pre>";
      }
      } else {
      echo "Not working";
      echo 'SQLSTATE: '.$db->ErrorNo()."<br >";
      echo 'Message: '.$db->ErrorMsg()."<b r><br>";
      }
      [/PHP]

      Comment

      Working...