Error: ORA-12541 listener not found!
今天終於試成功了! 我把這些過程寫下, 希望對你有點幫助!
- Make sure that Linux environment have following variables, before you start your apache server.
- You must have the hosts you want to connect configured in /etc/tnsnames.ora (according to TNS_ADMIN's location)
(ADDRESS = (PROTOCOL = TCP)(HOST = db)(PORT = 1522))
(SERVICE_NAME = TEST)
- Your PHP must compiled with oci8(Oracle DB) support, try:
to see if you see oci8 libraries available.
- Try to make connection from the Host to Oracle DB first to make sure that connection is available. And you should be inside Oracle shell
Connected to:Oracle9i Enterprise Edition Release 126.96.36.199.0 - 64bit ProductionWith the Partitioning, OLAP and Oracle Data Mining optionsJServer Release 188.8.131.52.0 - Production
- Using ADODB DB abstraction tool is an easy way to connect Oracle. If method A won't work, try method B
in PHP include('include/adodb/adodb.inc.php');
include('adodb/tohtml.inc.php'); //This for debug output
$ADODB_CACHE_DIR = '/tmp/ADODB_cache';
oracle_conn = &ADONewConnection('oci8');
oracle_conn->connectSID = true;//If you are using SID to connect, you must have this line
oracle_conn->Connect($ORACLE_HOST, $ORACLE_USER_ID, $ORACLE_USER_PASSWORD, $ORACLE_DATABASE_SID)
oracle_conn->Connect(false, $ORACLE_USER_ID, $ORACLE_USER_PASSWORD, $ORACLE_DATABASE_SID)
After this, you should be able to connect to Oracle DB using PHP