The C-program I'm writing tries to connect to Oracle database with olog():
olog(&lda, (ub1 *)hda, dbparam_keys[DbUser].value, -1,
dbparam_keys[DbPassword].value, -1, NULL, -1, (ub4)OCI_LM_DEF);
This fails with ORA-12545, because I specify neither the server's hostname, nor the port number anywhere. I do not, because I do not know, how to do that...
The "demos" bundled with the client seem to presume a valid tnsnames.ora -- is having that file mandatory for OCI API, or a can a client program, that knows the necessary values, specify them to the library (such as with OCIAttrSet()) all by itself?
There, likely, exists a better way, but the following works. The connection-specifier -- the third string passed to
olog()-- normally refers to an entry found intnsnames.ora. But, instead of being such a shortcut, it can also be the entire entry, which is what I want in this case.So, I'm using the complete syntax normally used in
tnsnames.orato describe the server in my code. I then pass the text as the connection-specifier toolog():