2011-04-18 84 views
1

PHP的錯誤,我有這樣的代碼:當連接到Oracle 10g R2

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數據庫,但我得到這個錯誤,我不知道爲什麼

是什麼問題?

回答

2

的問題是顯而易見的,SQLNET超時。原因並不總是那麼明顯。

從檢查主機連接開始檢查主機連接: telnet 1.1.1.1 1521 如果您看到空白屏幕而沒有錯誤消息,表示您的主機連接正常。 如果您的連接被拒絕:您的偵聽器沒有運行,或者至少沒有運行在指定的端口上。 如果你根本沒有得到任何迴應,請檢查防火牆[s]。

如果這是好的,我們可以深入挖掘。

+0

我可以運行這個命令telnet 1.1.1.1 1521,可以指定嗎? – Saleh 2011-04-18 10:45:37

+0

從運行php服務器的主機。該主機應該能夠連接到數據庫服務器的偵聽器。 – 2011-04-18 10:56:29

+0

我正在連接超時失敗,並且我使用程序終端仿真器連接 – Saleh 2011-04-18 11:30:49

0

連接超時表明它無法到達目的地(IP地址),您所提供。

這可能是因爲:

  • 要連接被防火牆限制了服務器
  • 您正在使用的IP地址和/或端口不正確
  • 服務器本身目前下降。
相關問題