开发者

Oracle: API for dealing with TNS file? [closed]

开发者 https://www.devze.com 2022-12-20 11:19 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can b开发者_StackOverflow中文版e answered with facts and citations.

Closed 4 years ago.

Improve this question

Is there an API that will read a TNS file and present it in some easy-to-use data structure?

I would like to get a list of all my TNS entries. This works but is not particularly elegant!

grep '^[a-zA-Z].*=' /etc/tnsnames.ora | sed 's/[ =].*//'


Another, not very simple, solution is ANTLR. You can use ANTLR to parse tnsnames.ora. On ANTLR Grammar List page you will find grammar which can parse tnsnames.ora, sqlnet.ora and listener.ora


I'm not sure if TNSPing would be more useful to you. It will output like:

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production
on 01-MAR-2009 02:02:33

Copyright (c) 1997, 2005, Oracle.  All rights reserved.

Used parameter files:

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)
(HOST = myhostname)(PORT = 1521)) (CONNECT_DATA = (SID = mydb)))
OK (80 msec)

The problem is you must pass it the TNS name to ping, which may or may not be possible in your scenario.

0

精彩评论

暂无评论...
验证码 换一张
取 消