2011-04-19 09:54

[Oracle] PDO-OCI 的 DSN 連接字串

最近重裝我的開發環境,結果連 oracle 一直連不上,出現了以下幾種訊息,最後是因為我的 TNS listener 沒設好,或是我的 DSN 錯誤,整理出我試過的幾個 DSN 連接字串:

ORA-12154: TNS:could not resolve service name
ORA-06401: NETCMN: invalid driver designator
ORA-12514: TNS:listener could not resolve SERVICE_NAME
ORA-12505: TNS:listener could not resolve SID given in connect descriptor

  1. $DSN="oci:dbname=jaxdb;charset=utf-8"; 
  2.  
  3. $DSN="oci:dbname=127.0.0.1:1521/jaxdb;charset=utf-8"; 
  4.  
  5. $DSN = "oci:dbname=( 
  6.    DESCRIPTION = ( 
  7.        ADDRESS_LIST = ( 
  8.            ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521) 
  9.        ) 
  10.    )(CONNECT_DATA= 
  11.        (SID = jaxdb) 
  12.    ) 
  13. );charset=utf8"; 
  14.  
  15. $DSN = "oci:dbname=( 
  16.    DESCRIPTION = ( 
  17.        ADDRESS_LIST = ( 
  18.            ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521) 
  19.        ) 
  20.    )(CONNECT_DATA= 
  21.        (SERVICE_NAME = jaxdb) 
  22.    ) 
  23. );charset=utf8"; 

0 回應: