As it turns out, yes, we can.
An average descriptor in TnsNames.ora will look something like this:
Code: Select all
DescriptorName = (
DESCRIPTION =
(
ADDRESS = (PROTOCOL = TCP) (HOST = server.host.lan) (PORT = 1521)
)
(
CONNECT_DATA =
(SERVICE_NAME = DBNAME)
)
)
Code: Select all
DescriptorName=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=server.host.lan)(PORT = 1521))(CONNECT_DATA=(SERVICE_NAME=DBNAME)))
Code: Select all
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=server.host.lan)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=DBNAME)))
I'm only writing this "guide" because I remembered reading something similar but never got any confirmation.
I wrote a TnsNames.ora parser for... reasons, which handles each descriptor as a separate class and can be serialized to a TnsNames.ora accepted string format. This class can be used to build your connection string on the fly, without care of the actual format itself.
I'll publish it once the final refinements are completed.
Now you know. The curse of TnsNames.ora nightmare can finally be lifted.
Happy hardcoding!