PHP 5 连接到 Oracle 9.2
我在从 PHP5 连接到 Oracle 9.2 时遇到困难。我已经尝试过 OCI 1.4.2 和 1.4.5,并且能够连接到 Oracle 10g 及更高版本。我设置了一个测试数据库连接脚本,如下所示:
PHP 代码:
echo "Testing Connection...";
ociinternaldebug(1);
$conn = oci_new_connect('someuser', 'somepassword', '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.0.0.2 )(PORT = 1521)) (CONNECT_DATA = (SID = ORCL)))');
if (!$conn) {
$e = oci_error();
print_r ($e);
}
else
{
echo('Successful');
}
我收到此错误:
OCI8 DEBUG: OCINlsEnvironmentVariableGet at (ext\oci8\oci8.c:1826) OCI8 DEBUG L1: using shared pool: (0x2078b68) at (ext\oci8\oci8.c:3028) OCI8 DEBUG: OCIHandleAlloc at (ext\oci8\oci8.c:3039) OCI8 DEBUG: OCIHandleAlloc at (ext\oci8\oci8.c:3049) OCI8 DEBUG: OCIAttrGet at (ext\oci8\oci8.c:3082) OCI8 DEBUG: OCIAttrGet at (ext\oci8\oci8.c:3083) OCI8 DEBUG L1: (numopen=0)(numbusy=0) at (ext\oci8\oci8.c:3085) OCI8 DEBUG: OCISessionGet at (ext\oci8\oci8.c:3096) OCI8 DEBUG: OCIErrorGet at (ext\oci8\oci8.c:1632) OCI8 DEBUG: OCIHandleFree at (ext\oci8\oci8.c:2218) OCI8 DEBUG: OCIHandleFree at (ext\oci8\oci8.c:2221) OCI8 DEBUG: OCIErrorGet at (ext\oci8\oci8.c:1632) Array ( [code] => 1017 [message] => **ORA-01017: invalid username/password; logon denied** [offset] => 0 [sqltext] => )
I'm have difficulty connecting from PHP5 to Oracle 9.2. I've tried both 1.4.2 and 1.4.5 of OCI and I am able to connect to Oracle 10g and up. I've setup a test db connection script as follows:
PHP Code:
echo "Testing Connection...";
ociinternaldebug(1);
$conn = oci_new_connect('someuser', 'somepassword', '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.0.0.2 )(PORT = 1521)) (CONNECT_DATA = (SID = ORCL)))');
if (!$conn) {
$e = oci_error();
print_r ($e);
}
else
{
echo('Successful');
}
I get this error:
OCI8 DEBUG: OCINlsEnvironmentVariableGet at (ext\oci8\oci8.c:1826) OCI8 DEBUG L1: using shared pool: (0x2078b68) at (ext\oci8\oci8.c:3028) OCI8 DEBUG: OCIHandleAlloc at (ext\oci8\oci8.c:3039) OCI8 DEBUG: OCIHandleAlloc at (ext\oci8\oci8.c:3049) OCI8 DEBUG: OCIAttrGet at (ext\oci8\oci8.c:3082) OCI8 DEBUG: OCIAttrGet at (ext\oci8\oci8.c:3083) OCI8 DEBUG L1: (numopen=0)(numbusy=0) at (ext\oci8\oci8.c:3085) OCI8 DEBUG: OCISessionGet at (ext\oci8\oci8.c:3096) OCI8 DEBUG: OCIErrorGet at (ext\oci8\oci8.c:1632) OCI8 DEBUG: OCIHandleFree at (ext\oci8\oci8.c:2218) OCI8 DEBUG: OCIHandleFree at (ext\oci8\oci8.c:2221) OCI8 DEBUG: OCIErrorGet at (ext\oci8\oci8.c:1632) Array ( [code] => 1017 [message] => **ORA-01017: invalid username/password; logon denied** [offset] => 0 [sqltext] => )
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 sqlplus 从同一台机器/使用相同的用户名/密码登录到同一数据库吗?
Can you logon to the same database using sqlplus from the same machine / with same username/password?
您的密码是否可能存在某些字符集问题?您的客户端或服务器之一不支持其中的字符吗? Mabye PHP 错误地转换了字符,或者可能在您使用 SQL*Plus 时错误地转换了字符,并且发送了“正确”版本
PHP 对服务器来说似乎是错误的。
运行此查询以查看服务器实际在做什么。如果返回代码为 1017,则服务器获取的用户名或密码错误。
我认为我从未见过 Oracle 错误消息是谎言。但我看到一些程序误解了错误消息。例如,如果您的密码已过期但您有宽限期,Oracle 将返回错误但仍允许您登录。 SQL*Plus 会警告“ORA-28002:密码将在 8 天内过期”,但某些程序会错误地将其解释为登录失败
甚至可能会说“错误的用户名/密码”。但这是 Oracle 产品,并且显示 Oracle 错误代码,因此可能性不大。
Is it possible your password has some character set issues? Is there a character in there that is not supported by one of your clients or servers? Mabye PHP incorrectly converts the characters, or maybe they are incorrectly converted whenever you use SQL*Plus, and the "correct" version sent
by PHP appears wrong to the server.
Run this query to see what the server is actually doing. If the return code is 1017 then the server is getting the wrong username or password.
I don't think I've ever seen an Oracle error message lie. But I have seen some programs misinterpret the error messages. For example, if your password is expired but you've got a grace period Oracle will return an error but still allow you to login. SQL*Plus will warn "ORA-28002: the password will expire within 8 days", but some programs will incorrectly interpret this as a login failure
and may even say "bad username/password". But this is an Oracle product, and it's displaying an Oracle error code, so that's a long shot.