Reputation: 105
I am trying to connect to an external database (not my localhost database).
My login details are (made up details of course). I use these login details to login successfully using oracle's sql developer.
Username: COOLDB123
Password: ThisIsADB123
Hostname: oracle.mywebsite.com
Port: 1521
Service name (NOT SID, I don't use a SID): pdb.oracle.mywebsite.com
login-script.php
<?php
$db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = oracle.mywebsite.com)(PORT = 1521)))(CONNECT_DATA=(SID=pdb.oracle.mywebsite.com)))" ;
if($c = OCILogon("COOLDB123", "ThisIsADB123", $db))
{
echo "Successfully connected to Oracle.\n";
OCILogoff($c);
}
else
{
$err = OCIError();
echo "Connection failed.";
}
?>
However, I get the error:
Warning: ocilogon(): ORA-01017: invalid username/password; logon denied in C:\xampp\htdocs\test.php on line 4
Connection failed.
I know for a fact the details are correct because I can log into my database using Oracle's SQL developer. What am I doing wrong? I am suspecting that in my $db
part I am putting SID
instead of the service name. However, I am unsure of the syntax for the service name.
Upvotes: 2
Views: 1911
Reputation: 105
To add the service name I have to change $db
to:
$db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = oracle.mywebsite.com)(PORT = 1521)))(CONNECT_DATA=(SERVICE_NAME=pdb.oracle.mywebsite.com)))" ;
Upvotes: 1