Db2 connection problem with IBM DB2
I am trying to connect a db2 database using php. Now, i am gonna write some code similar to this(call a stored procedure):
$proc = 'CALL MyLib.MySP(?, ?, ?)';
$stmt = db2_prepare($conn, $proc) or die("db2_prepare failed<br>");
// Define input variable values //
$paramIN1 = ...;
$paramIN2 = ...;
$paramOUT3 = "";
// Define parameters //
db2_bind_param($stmt, 1, "paramIN1", DB2_PARAM_IN);
db2_bind_param($stmt, 2, "paramIN2", DB2_PARAM_IN);
db2_bind_param($stmt, 3, "paramOUT3", DB2_PARAM_OUT);
// Display results set //
if (db2_execute($stmt)) {
while ($row = db2_fetch_array($stmt)) {
print " {$row[0]}, {$row[1]}, {$row[5]}<br>";
}
}
Connection code:
$user = 'user';
$password = 'pass';
$hostname = 'ip';
$db = 'db';
$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};HOSTNAME=$hostname;PROTOCOL=TCPIP;UID=$user;PWD开发者_StackOverflow=$password;DATABASE=$db;";
$conn = db2_connect($conn_string, $user, $password);
Connection fails here. Error message returned from db2_conn_errormsg() is:
"[IBM][CLI Driver] SQL1032N No start database manager command was issued. SQLSTATE=57019 SQLCODE=-1032"
This is an AS/400 system. With odbc we can connect and talk to database without a problem.
[IBM][CLI Driver] is the DB2 ODBC driver not the iSeries Access ODBC driver. From what I can discern it also requires DB2 Connect to enable a connection to an AS/400 host.
A failure to connect using the iSeries Access ODBC driver results in the following message:
[IBM][iSeries Access ODBC Driver]Communication link failure. comm rc=8015 - CWBSY1006 - User ID is invalid, Password length = 0, Prompt Mode = Never, System IP Address = 127.0.0.1
Check the database driver on your ODBC DSN.
You can connect with db2 using:
$dbh = db2_connect('*LOCAL', $user, $password, array("i5_lib"=> $db);
If the DB2 database and the ZendServer are in the same IBM i then '*LOCAL', else the DB2 name.
精彩评论