PHP 5 连接到 Oracle 9.2

发布于 2024-10-30 19:10:59 字数 1308 浏览 0 评论 0原文

我在从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

若水微香 2024-11-06 19:10:59

您可以使用 sqlplus 从同一台机器/使用相同的用户名/密码登录到同一数据库吗?

Can you logon to the same database using sqlplus from the same machine / with same username/password?

墟烟 2024-11-06 19:10:59

您的密码是否可能存在某些字符集问题?您的客户端或服务器之一不支持其中的字符吗? Mabye PHP 错误地转换了字符,或者可能在您使用 SQL*Plus 时错误地转换了字符,并且发送了“正确”版本
PHP 对服务器来说似乎是错误的。

运行此查询以查看服务器实际在做什么。如果返回代码为 1017,则服务器获取的用户名或密码错误。

select userid, userhost, terminal, returncode, ntimestamp#
from sys.aud$
order by ntimestamp# desc;

我认为我从未见过 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.

select userid, userhost, terminal, returncode, ntimestamp#
from sys.aud$
order by ntimestamp# desc;

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文