0

I am trying to perform tnsping to a server with java. I am trying to retrieve the port number and hostname of a database.

Locally I have installed the oracle universal installer. I will do a tnsping with a name I get something like this: `C:\oracle_db_home\network\admin\sqlnet.ora

Used LDAP adapter to resolve the alias Attempting to contact (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=amrpop000008656.test.com)(PORT=63000)))(CONNECT_DATA=(SERVICE_NAME=ia055653.test.com)))`

note: I don't have the tnsname.ora file in the server when I am executing this. sqlnet.ora and ldap.ora are configured to get it from another server.

I am trying to create an api that when you will give it the name of the database(as it is in the tnsname.ora) it will return the hostname and the port. The tricky part is that this API will run on AWS lamda so there is no tnsping functionality where the API is running.

I am using spring framework, so how do I utilize the sqlnet.ora and ldap.ora files that I have so I can get the response (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=amrvop000008656.test.com)(PORT=63000)))(CONNECT_DATA=(SERVICE_NAME=ia055653.test.com))) with java?

Executing an SSH command to perform tnsping is not doable in serverless where you can't install oracle.

PANTELIS
  • 1
  • 1
  • This sounds like it really isn't about `tnsping`, but about how to retrieve data from your LDAP server from Java? – Alex Poole Nov 29 '22 at 11:23
  • Yes, the end result is to get the information, tnsping is how I know to do it manually. If my API was running on a server with the oracle installed, I could have written code to execute the tnsping with openSSH or something similar. – PANTELIS Nov 29 '22 at 12:23
  • I am trying to see if there is an elegant way, a library or something similar instead of me going to the server pulling the tnsname.ora file and trying to exact the information. – PANTELIS Nov 29 '22 at 13:29
  • You might be able to adapt [this C# answer](https://stackoverflow.com/a/14586693/266304) to Java? I don't have an LDAP config to attempt that against... – Alex Poole Nov 29 '22 at 14:12

0 Answers0