Programing

SQL Developer에 새 연결을 추가 할 때 Oracle TNS 이름이 표시되지 않음

lottogame 2020. 9. 4. 08:02
반응형

SQL Developer에 새 연결을 추가 할 때 Oracle TNS 이름이 표시되지 않음


SQL Developer를 사용하여 Oracle 데이터베이스에 연결하려고합니다.

.Net oracle 드라이버를 설치하고 tnsnames.ora파일을
C:\Oracle\product\11.1.0\client_1\Network\Admin

tnsnames.ora에서 다음 형식을 사용하고 있습니다.

dev =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.XXX.XXX)(PORT = XXXX))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = idpdev2)
    )
  )

SQL Developer에서 새 연결을 만들려고 할 때 TNS 이름이 옵션으로 표시되지 않습니다.

내가 놓친 것이 있습니까?


SQL Developer는 tnsnames.ora 파일을이 순서대로 다음 위치에서 찾습니다.

  1. $ HOME / .tnsnames.ora
  2. $ TNS_ADMIN / tnsnames.ora
  3. 레지스트리의 TNS_ADMIN 조회 키
  4. /etc/tnsnames.ora (비 Windows)
  5. $ ORACLE_HOME / network / admin / tnsnames.ora
  6. LocalMachine \ SOFTWARE \ ORACLE \ ORACLE_HOME_KEY
  7. LocalMachine \ SOFTWARE \ ORACLE \ ORACLE_HOME

어떤 SQL 개발자가 사용 중인지 확인하려면 show tns워크 시트 에서 명령 을 실행하십시오.

tnsnames.ora 파일이 인식되지 않으면 다음 절차를 따르십시오.

  1. tnsnames.ora 파일이 포함 된 폴더를 가리 키도록 TNS_ADMIN 이라는 환경 변수를 정의 합니다.

    Windows에서는 제어판 > 시스템 > 고급 시스템 설정 > 환경 변수 ... 로 이동하여이 작업을 수행합니다 .

    Linux에서는 홈 디렉토리의 .profile 파일에 TNS_ADMIN 변수를 정의하십시오 .

  2. OS가이 환경 변수를 인식하는지 확인

    Windows 명령 줄에서 : echo % TNS_ADMIN %

    Linux에서 : echo $ TNS_ADMIN

  3. SQL Developer 다시 시작

  4. 이제 SQL Developer에서 Connections를 마우스 오른쪽 버튼으로 클릭 하고 New Connection ...을 선택 합니다 . 드롭 다운 상자에서 연결 유형으로 TNS선택 합니다. 이제 tnsnames.ora의 항목이 여기에 표시됩니다.

SQL Developer를 엽니 다. 도구-> 환경 설정-> 데이터베이스-> 고급으로 이동 한 다음 Tnsnames 디렉토리를 명시 적으로 설정합니다.

내 TNSNAMES가 올바르게 설정되었고 Toad, SQL * Plus 등에 연결할 수 있었지만 SQL Developer가 작동하도록하려면이 작업을 수행해야했습니다. 설치가 너무 힘들었 기 때문에 아마도 Win 7 문제 였을 것입니다.


에서는 SQLDeveloper 찾아 Tools --> Preferences이미지 아래에 도시 된 바와 같이. tnsnames.ora가

여기에 이미지 설명 입력

있는 환경 설정 옵션 expand Database --> select Advanced --> under "Tnsnames Directory" --> Browse the directory에서 . 다음을 클릭 확인 . 아래 다이어그램과 같이.


여기에 이미지 설명 입력

완료했습니다!

이제 TNSnames 옵션을 통해 연결할 수 있습니다.


연결을 확인하기 위해 TNSPING을 실행하여 사용중인 tnsnames.ora 파일의 위치를 ​​항상 찾을 수 있습니다 (9i 이상).

C:\>tnsping dev

TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 08-JAN-2009 12:48:38

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

Used parameter files:
C:\oracle\product\10.2.0\client_1\NETWORK\ADMIN\sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = XXX)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = DEV)))
OK (30 msec)

C:\>

Sometimes, the problem is with the entry you made in tnsnames.ora, not that the system can't find it. That said, I agree that having a tns_admin environment variable set is a Good Thing, since it avoids the inevitable issues that arise with determining exactly which tnsnames file is being used in systems with multiple oracle homes.


The steps mentioned by Jason are very good and should work. There is a little twist with SQL Developer, though. It caches the connection specifications (host, service name, port) the first time it reads the tnsnames.ora file. Then, it does not invalidate the specs when the original entry is removed from the tnsname.ora file. The cache persists even after SQL Developer has been terminated and restarted. This is not such an illogical way of handling the situation. Even if a tnsnames.ora file is temporarily unavailable, SQL Developer can still make the connection as long as the original specifications are still true. The problem comes with their next little twist. SQL Developer treats service names in the tnsnames.ora file as case-sensitive values when resolving the connection. So if you used to have an entry name ABCD.world in the file and you replaced it with an new entry named abcd.world, SQL Developer would NOT update its connection specs for ABCD.world - it will treat abcd.world as a different connection altogether. Why am I not surprised that an Oracle product would treat as case-sensitive the contents of an oracle-developed file format that is expressly case-insensitive?


In Sql Developer, navidate to Tools->preferences->Datababae->advanced->Set Tnsname directory to the directory containing tnsnames.ora


None of the above changes made any difference in my case. I could run TNS_PING in the command window but SQL Developer couldn't figure out where tnsnames.ora was.

The issue in my case (Windows 7 - 64 bit - Enterprise ) was that the Oracle installer pointed the Start menu shortcut to the wrong version of SQL Developer. There appear to be three SQL Developer instances that accompany the installer. One is in %ORACLE_HOME%\client_1\sqldeveloper\ and two are in %ORACLE_HOME%\client_1\sqldeveloper\bin\ .

설치 프로그램은 단순히 작동하지 않는 bin 디렉토리의 버전을 가리키는 시작 메뉴 바로 가기를 설치했습니다. SQL Developer를 시작할 때마다 암호를 묻습니다. 제가 선택한 사항을 기억하지 못하고 TNS를 연결 메커니즘으로 선택할 때 빈 목록을 표시했습니다. 또한 다른 게시물에서 참조 된 데이터베이스 고급 설정에 TNS 디렉토리 필드가 없습니다.

이전 시작 바로 가기를 버리고 % ORACLE_HOME % \ client_1 \ sqldeveloper \ sqldeveloper.exe 바로 가기를 설치했습니다. 그 변경으로 제 경우 문제가 해결되었습니다.

참고 URL : https://stackoverflow.com/questions/425029/oracle-tns-names-not-showing-when-adding-new-connection-to-sql-developer

반응형