IBM DB2 的 Db2 连接问题
我正在尝试使用 php 连接 db2 数据库。现在,我要编写一些类似于此的代码(调用存储过程):
$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>";
}
}
连接代码:
$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);
连接失败。从 db2_conn_errormsg() 返回的错误消息是:
"[IBM][CLI Driver] SQL1032N No start database manager command was issued. SQLSTATE=57019 SQLCODE=-1032"
这是一个 AS/400 系统。使用 odbc,我们可以毫无问题地连接并与数据库通信。
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=$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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
[IBM][CLI Driver] 是 DB2 ODBC 驱动程序不是 iSeries Access ODBC 驱动程序。据我所知,它还需要 DB2 Connect 来启用到 AS/400 主机的连接。
使用 iSeries Access ODBC 驱动程序连接失败会导致出现以下消息:
[IBM][iSeries Access ODBC Driver]通信链接失败。 comm rc=8015 - CWBSY1006 - 用户 ID 无效,密码长度 = 0,提示模式 = 从不,系统 IP 地址 = 127.0.0.1
检查 ODBC DSN 上的数据库驱动程序。
[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.
您可以使用以下方式连接 db2:
如果 DB2 数据库和 ZendServer 位于同一个 IBM i 中,则为“*LOCAL”,否则为 DB2 名称。
You can connect with db2 using:
If the DB2 database and the ZendServer are in the same IBM i then '*LOCAL', else the DB2 name.