问题
Is it possible to perform a TNSPing on an Oracle Database programmatically?
I'm aware I could probably call the TNSPing program and parse any output generated but I'm looking for a more robust method of handling the database TNS Ping.
Having seen the Ping class on MSDN, I tried to use the example code found, but I think I would need some way to resolve the TNS name into an actual IP address for this method to work. Is this possible?
回答1:
This Forum seems to suggest that attempting to use TNSPing is a waste of time and that actually attempting the connection would be of more use!
It seems that catching the exceptions that might get raised during communications with a database might be the only reliable way to test that an oracle database is still there.
回答2:
Not sure you can directly - it's the Oracle client software that resolves the TNS name to an IP address and I don't know of any call on the Oracle.DataAccess.Client that would do that for you.
来源:https://stackoverflow.com/questions/4367240/c-sharp-perform-a-tnsping-programmatically