By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,016 Members | 2,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,016 IT Pros & Developers. It's quick & easy.

DB2 PHP connection issue

P: 14
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 = ADONewConnection('db2');

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

I get the following error:
Expand|Select|Wrap|Line Numbers
  1. ***didn't work db->Connect(dsn)
  2. SQLSTATE: 42968
  3. Message: [IBM][CLI Driver] SQL8002N Connect processing failed; a valid product license was not found. SQLSTATE=42968 SQLCODE=-8002
  4.  
I know I am using the correct iSeries port, the correct DB name, and a fully licensed server. Has anyone ever seen this error?
Nov 13 '08 #1
Share this Question
Share on Google+
2 Replies


10K+
P: 13,264
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.
Nov 14 '08 #2

P: 14
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 = ADONewConnection('odbc');
$dsn = "DRIVER={iSeries Access ODBC Driver};SYSTEM=$Host;DATABASE=$DBName;PROTOCOL=TCP IP;PORT=$Port;";
if ($db->Connect($dsn,$User,$Password)){
echo "It worked";
$sql = "SELECT table_name, table_type, table_schema, system_table_name 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()."<br><br>";
}
[/PHP]
Nov 14 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.