[英]Db2 connection problem with IBM DB2
I am trying to connect a db2 database using php. 我正在尝试使用php连接db2数据库。 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=$password;DATABASE=$db;";
$conn = db2_connect($conn_string, $user, $password);
Connection fails here. 此处连接失败。 Error message returned from db2_conn_errormsg() is:
从db2_conn_errormsg()返回的错误消息是:
"[IBM][CLI Driver] SQL1032N No start database manager command was issued. SQLSTATE=57019 SQLCODE=-1032"
This is an AS/400 system. 这是一个AS / 400系统。 With odbc we can connect and talk to database without a problem.
使用odbc,我们可以毫无问题地连接数据库并与之对话。
[IBM][CLI Driver] is the DB2 ODBC driver not the iSeries Access ODBC driver. [IBM] [CLI驱动程序]是DB2 ODBC驱动程序,而不是iSeries Access ODBC驱动程序。 From what I can discern it also requires DB2 Connect to enable a connection to an AS/400 host.
据我所知,它还需要DB2 Connect才能连接到AS / 400主机。
A failure to connect using the iSeries Access ODBC driver results in the following message: 使用iSeries Access ODBC驱动程序连接失败导致以下消息:
[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. 检查ODBC DSN上的数据库驱动程序。
You can connect with db2 using: 您可以使用以下方法与db2连接:
$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. 如果DB2数据库和ZendServer在同一个IBM i中,则为'* LOCAL',否则为DB2名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.