java.sql.SQLException: Io 異常: The Network Adapter could not establish the connection是我今天剛遇到的問題,有很
多原因導致這個,網上也有答案,我的主要毛病是在hibernate.properties檔案中沒有把hibernate.properties中的行:
hibernate.connection.url jdbc:oracle:thin:@localhost:1521:oracle
最後一個oracle替換為我的oracle_sid,改成orcl後就沒事,還有一些解決方案。我一一列出:
1、把卡巴斯基防火牆關掉就好了
2、oracle/ora92/network/admin/listener.ora 和 oracle/ora92/network/admin/tnsnames.ora 的設定問題。
兩個檔案如下:
listener.ora:
# LISTENER.ORA Network Configuration File: F:/oracle/ora92/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = lei)(PORT = 1521))
)
)
)
#change 1521 to 1523 this is oracle92's listener
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = F:/oracle/ora92)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = F:/oracle/ora92)
(SID_NAME = orcl)
)
)
tnsnames.ora:
# TNSNAMES.ORA Network Configuration File: F:/oracle/ora92/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = lei)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
INST1_HTTP =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = lei)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = SHARED)
(SERVICE_NAME = MODOSE)
(PRESENTATION = http://HRService)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
比如,listener.ora中的host寫錯了。不同的版本所需要的portable也不會一樣的。
還是非常感謝大家!!