开发者

Error when tring to connect adodb to Oracle

I have installed WAMP ser开发者_JAVA百科ver.

When trying to connect to Oracle it gives this error:

ORA-12541: TNS:no listener

Anyone know how to solve this?


Either your listener isn't started (issue the command lsnrctl start) or your tnsnames.ora is wrong.


Make changes in php.ini file Enable oci driver uncomment by removing ; semicolon Check for the correct dll file and then

Try this simple class

class AdoConnection {

    public $dbh;

    public function __construct() {
        include_once '../adoconnection/adodb5/adodb.inc.php'; // include your adodb.inc.php file

        $server = "127.0.0.1";
        $user   = "USER/SCHEMA/Database";
        $pwd    = "password";
        $db     = "SID OR Service_Name";

        $this->dbh = NewADOConnection('oci8');
        $this->dbh->Connect(FALSE, $user, $pwd, '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ' . $server. ')(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = ' . $db . ') (SID = ' . $db . ')))');
    }

    public function select($sql) {
        $result = $this->dbh->Execute($sql);
        $result = $result->GetRows();
        return $result;
    }

    public function insert($sql) {
        $result = $this->dbh->Execute($sql);
        return $result;
    }
}

$dbh = new AdoConnection();

$dbh->select($sql);
$dbh->insert($sql);

Just keep your error_reporting and display_errors On to see the errors.

ini_set('display_errors',1);
error_reporting(E_ALL);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜