Reputation: 770
I am having difficulties to connect to remote db2 database using pdo_ibm, I followed the instructions on IBM to configure the pdo_ibm library and linux client but since my php is not configured manually but installed through apt-get I am not sure if current error might be due to a missconfiguration or anything else.
My stage is: Linux debian wheezy ibm db2 client 10.5 php 5.4.45 pdo_ibm 1.4
when I try to connect with db2 with the following code:
<?php
$usernameMaximo = '@user';
$passwordMaximo = '@password';
$connectionStringMaximo = 'ibm:DRIVER={IBM DB2 ODBC DRIVER};DATABASE=@databaseName;[email protected];PORT=50002;PROTOCOL=TCPIP;';
try {
$connection = new PDO($connectionStringMaximo, $usernameMaximo, $passwordMaximo, array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
);
echo "Success";
}
catch (Exception $e) {
var_dump($e);
}
I get the following error
object(PDOException)[2]
protected 'message' => string 'SQLSTATE= , SQLDriverConnect: -5005 [IBM][CLI Driver] SQL10007N Message "0" could not be retrieved. Reason code: "3".
' (length=123)
private 'string' (Exception) => string '' (length=0)
protected 'code' => int 0
protected 'file' => string '/apps/html/tests/pdo_db2.php' (length=28)
protected 'line' => int 8
private 'trace' (Exception) =>
array (size=1)
0 =>
array (size=6)
'file' => string '/apps/html/tests/pdo_db2.php' (length=28)
'line' => int 8
'function' => string '__construct' (length=11)
'class' => string 'PDO' (length=3)
'type' => string '->' (length=2)
'args' =>
array (size=4)
...
private 'previous' (Exception) => null
public 'errorInfo' => null
network/firewall is already check so I can connect through squirrel client, Anyone has faced the same problem?
Upvotes: 6
Views: 981
Reputation: 1759
Can you try to set the right NCIM instance name? by default:
DB2INSTANCE=db2inst1
To know if db2inst1 is the right name of DB2 instance, execute:
sudo su db2inst1
db2level
Response could be something like this:
DB21085I Instance "db2inst1" uses "64" bits and DB2 code release "SQL09074"
with level identifier "08050107".
Informational tokens are "DB2 v9.7.0.4", "s110330", "IP23243", and Fix Pack "4".
Product is installed at "/opt/ibm/db2/V9.7".
Upvotes: 3
Reputation:
Have you tried the alternative way provided here
The following example shows a PDO_IBM DSN for connecting to an DB2 database cataloged as DB2_MAXIMO in db2cli.ini:
$db = new PDO("ibm:DSN=DB2_MAXIMO", "", "");
[DB2_MAXIMO]
Database=SAMPLE
Protocol=TCPIP
Port=50002
Hostname=my-db2-machine
UID=my-OS-user
PWD=my-OS-password
Upvotes: 3