Problem to connect Oracle 19c
rootchips opened this issue · comments
Summary of problem or feature request
I tried to connect Oracle 19c DB in a different machine using simple script PHP. The connection is success, and I got response. But when I tried using Laravel, it response an error which is oci_connect(): ORA-01017: invalid username/password; logon denied
This is sample script PHP that I tested and it success (non-Laravel)
<?php
// Connects to the XE service (i.e. database) on the "localhost" machine
$conn = oci_connect('dummyx', 'passwordxx', '10.0.x.x/xxxx.xxxvcn.oraclevcn.com');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$stid = oci_parse($conn, 'SELECT * FROM employees');
oci_execute($stid);
echo "<table border='1'>\n";
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
echo "<tr>\n";
foreach ($row as $item) {
echo " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
?>
At oci_connect()
, I dont need to put "DB_DATABASE", but I can query the table of employees.
this is my .env from Laravel
DB_CONNECTION=oracle
DB_HOST=10.0.x.x
DB_PORT=1521
DB_SERVICE_NAME=xxxx.xxxvcn.oraclevcn.com
DB_DATABASE=db
DB_USERNAME="dummyx"
DB_PASSWORD="passwordxx"
When I tried to ditch DB_DATABASE
, it thrown an error oci_connect(): ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA
.
Is there something I missed?
System details
- Oracle Linux 8
- PHP 8.1
- Laravel 8.75
- Laravel-OCI8 8.5
As I recall, the service name is case-sensitive. This might be the case here?
As I recall, the service name is case-sensitive. This might be the case here?
It was given/generated by Oracle Cloud Database VM. So I just followed it from there. Just curious why in PHP (Non-Laravel) can connect and query the table but Laravel can't connect.
It may not work due to how the connection is built. Behind the scene, the package composes a TNS connection string which might be the cause of the failure.
See ConnectorTest for example.
Sorry my mistake. I accidentally look at v9.x so I confused either DB_SERVICENAME or DB_SERVICE_NAME. Case closed. Thanks @yajra :)