1

我有这个代码:

ociinternaldebug(1);


// try connecting to the database
 $conn = oci_new_connect('username', 'password', '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 1.1.1.1 )(PORT = 1521)) (CONNECT_DATA = (SID = dpsid)))');

// check for any errors
 if (!$conn)
 {
  $e = oci_error();
  print htmlentities($e['message']);
  exit;
 } 

// else there weren't any errors
 else
 {
  echo 'connected.';
 } 

我得到这个错误:

    OCI8 DEBUG: OCINlsEnvironmentVariableGet at (ext\oci8\oci8.c:1758) OCI8 DEBUG: OCIEnvNlsCreate at (ext\oci8\oci8.c:2708) OCI8 DEBUG: OCIHandleAlloc at (ext\oci8\oci8.c:2568) OCI8 DEBUG: OCIHandleAlloc at (ext\oci8\oci8.c:2580) OCI8 DEBUG: OCISessionPoolCreate at (ext\oci8\oci8.c:2598) OCI8 DEBUG: OCIAttrSet at (ext\oci8\oci8.c:2610) OCI8 DEBUG L1: create_spool: (0x1dde4f0) at (ext\oci8\oci8.c:2626) OCI8 DEBUG L1: using shared pool: (0x1dde4f0) at (ext\oci8\oci8.c:2904) OCI8 DEBUG: OCIHandleAlloc at (ext\oci8\oci8.c:2915) OCI8 DEBUG: OCIHandleAlloc at (ext\oci8\oci8.c:2925) OCI8 DEBUG: OCIAttrGet at (ext\oci8\oci8.c:2958) OCI8 DEBUG: OCIAttrGet at (ext\oci8\oci8.c:2959) OCI8 DEBUG L1: (numopen=0)(numbusy=0) at (ext\oci8\oci8.c:2961) OCI8 DEBUG: OCISessionGet at (ext\oci8\oci8.c:2972) OCI8 DEBUG: OCIErrorGet at (ext\oci8\oci8.c:1571) 
Warning: oci_new_connect() [function.oci-new-connect]: ORA-12170: TNS:Connect timeout occurred in C:\wamp\www\view\test.php on line 21
OCI8 DEBUG: OCIHandleFree at (ext\oci8\oci8.c:2150) OCI8 DEBUG: OCIHandleFree at (ext\oci8\oci8.c:2153) OCI8 DEBUG: OCIErrorGet at (ext\oci8\oci8.c:1571) ORA-12170: TNS:Connect timeout occurred

我正在尝试连接到远程 Oracle 数据库,但出现此错误,我不知道为什么

问题是什么?

4

2 回答 2

2

问题很明显,sqlnet超时。原因并不总是那么明显。

从检查主机连接开始: telnet 1.1.1.1 1521 如果您得到一个空白屏幕而不是错误消息,则您的主机连接正常。如果你得到连接被拒绝:你的监听器没有运行,或者至少没有在指定的端口上运行。如果您根本没有得到任何响应,请检查防火墙[s]。

如果没问题,我们可以深入挖掘。

于 2011-04-18T10:26:54.673 回答
0

Connect timeout suggests it cannot reach the destination (IP address) you've provided.

This could be because:

  • The server you're connecting to is restricted by a firewall
  • The IP address and/or port you're using is incorrect
  • The server itself is currently down.
于 2011-04-18T09:52:29.790 回答