繁体   English   中英

从 PHP 连接到 db2 数据库时 SQLCODE=-5005

[英]SQLCODE=-5005 while connecting to db2 database from PHP

我正在测试 PHP + Db2 连接。 我正在关注这个 URL - https://github.com/php/pecl-database-ibm_db2/blob/master/README.md

我有这个示例代码:

<?php
$database = 'casedb';
$user = 'db2test';
$password = 'XXXXXXX';
$conn = db2_connect($database, $user, $password);
echo "IN";
if ($conn) {
    echo "Connection succeeded.";
    db2_close($conn);
}
else {
    echo "Connection failed: " . db2_conn_errormsg();
}
echo "OUT";
?>

如果我将它作为独立的 PHP 程序运行,则连接成功。

# php connect.php
INConnection succeeded.OUT

如果我通过网络浏览器打开这个 PHP 页面,它会显示这个错误: http://9.30.XX.XX/connect.php

INConnection failed: [IBM][CLI Driver] SQL10007N Message "0" could not be retrieved. Reason code: "3". SQLCODE=-5005OUT

不确定这个 SQL5005 错误来自哪里。

SQL5005C  The operation failed because the database manager failed to
      access either the database manager configuration file or the
      database configuration file.
Explanation: 
The DB2 database product uses two types of configuration files:
Database manager configuration file
         Created when a DB2 database manager instance is created, the
     database manager configuration file contains parameters that
     affect system resources at the instance level. There is also
     one database manager configuration file for each client
     installation, which contains information about the client
     enabler for a specific workstation. The database manager
     configuration file is named db2systm and is located in the
     instance directory.
Database configuration file
         Created when a database is created, the database configuration
     file contains parameters that affect the use of that database.
     The database configuration file for each database is named
     SQLDBCONF, and stored along with other control files for that
     database in the directory named "SQLnnnnn" (where nnnnn is a
     number assigned when the database was created.)

我为目标数据库配置了 db2cli.ini。 还是没有成功。

请问有什么提示吗? 谢谢你。

回顾下面的问答应该很不错:

如何使用 PHP Locale 函数

它告诉我们需要:
setlocale(LC_ALL, $locale) 和 localeconv()

并尝试设置以下之一:“美国”、“美国”、“美国”、“美国”或“我们”
其他国家/地区/价值观见下文:
http://msdn.microsoft.com/en-us/library/cdax410z%28v=vs.90%29.aspx

希望这可以帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM