IP로 Oracle에 접속이 되지 않는 경우 - java.sql.SQLException: IO 예외 상황: The Network Adapter could not establish the connection

CODEDRAGON Development/JSP

반응형

 

 

   

IP로 Oracle에 접속이 되지 않는 경우 (해결방법)

  • tnsnames.ora, listener.ora파일 수정하기
  • listener.ora 파일에 설정 추가하기
  • 오라클 서비스 재시작

   


외부에서 원격접속시 접속안된다면 방화벽 설정도 체크해 보시기 바랍니다.

   

   

   

오류메시지

String dbURL = "jdbc:oracle:thin:@192.168.0.2:1521:orcl";

   

java.sql.SQLException: IO 예외 상황: The Network Adapter could not establish the connection

   

java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
192.168.0.2:1521:orcl

   

   

 

tnsnames.ora, listener.ora파일 수정하기

tnsnames.ora, listener.ora파일의 localhost를 해당 PC의 IP로 수정합니다.

   

C:\CodeLab\Oracle\product\11.2.0\dbhome_1\NETWORK\ADMIN\tnsnames.ora

tnsnames.ora

   

   

   

listener.ora

   

   

   

 

listener.ora 파일에 설정 추가하기

listener.ora파일에 아래의 내용을 추가합니다.

(SID_DESC =
//위에서 확인 한 SID 설정
      (SID_NAME = orcl)
//oracle 파일 위치 설정
      (ORACLE_NAME = C:\CodeLab\Oracle\product\11.2.0\dbhome_1)
   
      )

   

   

# listener.ora Network Configuration File: C:\CodeLab\Oracle\product\11.2.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
   
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\CodeLab\Oracle\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:C:\CodeLab\Oracle\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
(SID_DESC =
(SID_NAME = orcl)
(ORACLE_NAME = C:\CodeLab\Oracle\product\11.2.0\dbhome_1)
)
)
   
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.2)(PORT = 1521))
)
)
   
ADR_BASE_LISTENER = C:\CodeLab\Oracle
  

   

   

 

오라클 서비스 재시작

아래와 같은 메시지가 나온다면 실행 권한이 없으므로 관리자 권한으로 다시 실행하시기 바랍니다.

C:\CodeLab>lsnrctl start
   
LSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 28-6월 -2016 13:34:27
   
Copyright (c) 1991, 2010, Oracle. All rights reserved.
   
TNS-01106: LISTENER 리스너명을 이용한 리스너는 이미 시작되었습니다
   
C:\CodeLab>lsnrctl stop
   
LSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 28-6월 -2016 13:34:32
   
Copyright (c) 1991, 2010, Oracle. All rights reserved.
   
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))에 연결되었습니다
TNS-01190: 해당 사용자는 요청된 리스너 명령을 실행할 권한이 없습니다.
   
C:\CodeLab>

      

   
C:\CodeLab>lsnrctl stop
   
LSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 28-6월 -2016 13:36:29
   
Copyright (c) 1991, 2010, Oracle. All rights reserved.
   
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))에 연결되었습니다
명령이 성공적으로 수행되었습니다
   
C:\CodeLab>lsnrctl start
   
LSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 28-6월 -2016 13:36:35
   
Copyright (c) 1991, 2010, Oracle. All rights reserved.
   
시작 tnslsnr: 잠시만 기다리세요...
   
TNSLSNR for 64-bit Windows: Version 11.2.0.1.0 - Production
시스템 매개변수 파일은 C:\CodeLab\Oracle\product\11.2.0\dbhome_1\network\admin\listener.ora 입니다
c:\codelab\oracle\diag\tnslsnr\CODEDRAGON\listener\alert\log.xml (으)로 로그 메 시지를 기록했습니다
리스닝이: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
리스닝이: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.0.2)(PORT=1521)))
   
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))에 연결되었습니다
리스너의 상태
------------------------
별칭 LISTENER
버전 TNSLSNR for 64-bit Windows: Version 11.2.0.1.0 - Production
시작 날짜 28-6월 -2016 13:36:41
업타임 0 일 0 시간. 0 분. 5 초
트레이스 수준 off
보안 ON: Local OS Authentication
SNMP OFF리스너 매개변수 파일 C:\CodeLab\Oracle\product\11.2.0\dbhome_1\network\admin\listener.ora
리스너 로그 파일 c:\codelab\oracle\diag\tnslsnr\CODEDRAGON\listener\alert\log.xml
끝점 요약 청취 중...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.0.2)(PORT=1521)))
서비스 요약...
"CLRExtProc" 서비스는 1개의 인스턴스를 가집니다.
"CLRExtProc" 인스턴스(UNKNOWN 상태)는 이 서비스에 대해 1 처리기를 가집니다.
명령이 성공적으로 수행되었습니다
   
C:\CodeLab>

   

C:\CodeLab>tnsping 192.168.0.2
   
TNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 28-6월 -2016 13:38:29
   
Copyright (c) 1997, 2010, Oracle. All rights reserved.
   
사용된 매개변수 파일:
C:\CodeLab\Oracle\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
   
별칭 분석을 위해 EZCONNECT 어댑터 사용
(DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.2)(PORT=1521)))에 접속하려고 시도하는 중
확인(10밀리초)
   
C:\CodeLab>

   

   

   

실행결과

 

 

 

 

반응형

'Development > JSP' 카테고리의 다른 글

주석(Comments)  (0) 2016.09.12
JSP Architecture  (0) 2016.09.02
Tomcat *.xml설정 파일의 한글 주석 처리  (0) 2016.08.24
"helloWorld" Dynamic Web Project 생성  (0) 2016.08.19
톰캣(Tomcat)과 이클립스(eclipse) 연동 하기  (1) 2016.08.07