PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB » Bug #8719

ORACLE 10: can't connect to db

Details

Submitted2006-09-17 09:35 UTC
Fromdruid dot taliesin at gmail dot com
Assignedaharvey
StatusClosed
PackageDB
PHP Version5.1.6
OSwindows, linux
Roadmaps(Not assigned)

Comments

[2006-09-17 09:35 UTC] druid dot taliesin at gmail dot com

Description:
------------
If a connection to an oracle 10 database is made, the connection fail with the following message:

DB Error: connect failed

I've tried to sniffing network traffic with ethereal to discover possible error return from oracle and I find there is no traffic between my machine and the server, so I think it is a library problem.

After some test I find that there is an incorrect parameter in the call to oci_connect, the "string db" parameter.

If I re-define $db before call to oci_connect (about line 237 of oci8.php) to:

$db = '(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)
(HOST = '. $dsn['hostspec'] .')(PORT = '. $dsn['port'] .'))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = '. $dsn['database'] .')
)
)';

all gone well.

Test script:
---------------
<?php
require_once 'DB.php';

$dsn = 'oci8://control_center:suporto@192.168.0.13:1521/ORALSI';
$options = array(
'debug' => 2,
'portability' => DB_PORTABILITY_ALL,
);

$db =& DB::connect($dsn, $options);
if (PEAR::isError($db)) {
die($db->getMessage());
}

// ...

$db->disconnect();
?>

Expected result:
----------------
If the connection is establisehd, nothing on output.

Actual result:
--------------
DB Error: connect failed

[2006-12-18 15:58 UTC] chris-manjoine at uiwoa dot edu

your problem is that you dont need to include the database
your connecting to if your using the correct syntax e.g.

$tns='(DESCRIPTION=
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle.server.com)
(PORT = 1521))
)
(CONNECT_DATA =
(SID = databasename)
)
)';

define(_databaseDSN,'oci8://username:password@'.
rawurlencode($tns));

notice that there is no database name defined as it is in
the hostspec! this works flawlessly for me. Thanks for the
bug though it led me to the solution!

[2007-01-24 17:43 UTC] coco2001 at hotmail dot com

Thank you, Adam. This works for me.