[Interest] Oracle client does not read tnsnames.ora
Mathias Waack
mathias.waack at rantzau.de
Thu Apr 6 11:10:53 CEST 2017
Hello,
I have to fix a bug in an older application which connects to an oracle
DB. I was able to compile and start the app with Qt 5.6, but the connect
to Oracle fails with ORA-12545. That is a bit surprising, because tools
like sqlplus run on the same machine in the same environment. strace
shows, that the app does not read the tnsnames.ora file:
strace -f
../build-suptool.linux-Desktop_Qt_5_6_2_GCC_64bit2-Debug/suptoolserver
-c server/maw_server.cfg 2>&1 |grep "\.ora"
lstat("/usr/lib/oracle/12.2/client64/env.ora", 0x7ffd48cd0a60) = -1
ENOENT (No such file or directory)
open("/usr/lib/oracle/12.2/client64/env.ora", O_RDONLY) = -1 ENOENT (No
such file or directory)
access("/usr/lib/oracle/12.2/client64/network/admin/sqlnet.ora", F_OK) = 0
open("/usr/lib/oracle/12.2/client64/network/admin/sqlnet.ora", O_RDONLY) = 4
access("/home/mwaack/.sqlnet.ora", F_OK) = -1 ENOENT (No such file or
directory)
access("/usr/lib/oracle/12.2/client64/network/admin/sqlnet.ora", F_OK) = 0
open("/usr/lib/oracle/12.2/client64/network/admin/sqlnet.ora", O_RDONLY) = 7
access("/etc/intchg.ora", F_OK) = -1 ENOENT (No such file or
directory)
access("/usr/lib/oracle/12.2/client64/network/admin/intchg.ora", F_OK) =
-1 ENOENT (No such file or directory)
access("/etc/tnsnav.ora", F_OK) = -1 ENOENT (No such file or
directory)
access("/usr/lib/oracle/12.2/client64/network/admin/tnsnav.ora", F_OK) =
-1 ENOENT (No such file or directory)
The connect to the database is straight forward:
oradb = QSqlDatabase::addDatabase("QOCI","oradb");
if (!oradb.isValid()) throw ServerError("cannot load oracle database");
settings.beginGroup("db");
oradb.setDatabaseName(settings.value("name").toString());
oradb.setUserName(settings.value("user").toString());
oradb.setPassword(settings.value("pass").toString());
Q_ASSERT(oradb.hostName().isEmpty());
bool ok = oradb.open();
The last call to oradb.open() fails.
ORACLE_HOME is set correctly (obviously the oracle libs are able to find
the sqlnet.ora), I've also tried setting/unsetting TNS_ADMIN, without
any result. I am using the instant client for oracle.
So I am fairly sure this is not a Qt problem, but I hope to find someone
using Oracle from Qt who have a clue whats going on here.
Mathias
More information about the Interest
mailing list