一、The Network Adapter could not establish the connection
這個異常的出現一般與數據庫和你的PC的設置有關
這種異常的出現大致上有下面幾種:
1。IP錯誤。
在設置URL時錯誤,例如:jdbc:oracle:thin:@192.168.0.36:1521:sharp
數據庫服務器不正確:ping 服務器IP是否正確。不正確,將URL更改為正確
端口號錯誤:一般不會錯誤。
進行一下操作:在DOS上鍵入sqlplus,檢查oracle是否開啟
一卻正常,執行下面第2步。
2。防火牆
如果機器上安裝有放火牆,可能是服務器端口號屏蔽而造成的。關閉防火牆后,嘗試重新連接。
仍然不行,執行第3步。
3。數據庫監聽未啟動
i:linux上,啟動監聽:
lsnrctl status
lsnrctl stop
lsnrctl start
ii:windows啟動監聽
修改PC上注冊表中的ImagePath值。
我下面以現在主流的數據庫ORACLE為例
重新手動啟動數據庫監聽:
1:開始 → 運行→ 輸入CMD→ 進入DOS命令提示界面
d:>lsnrctl
LSNRCTL> status
或者
LSNRCTL> start
如果是類似圖片中的信息

恭喜,你的問題已經查找出來,是數據庫監聽器沒未啟動而造成的。
以下是手動啟動數據庫的方法:
在運行處執行regedit進入注冊表到
開始 →運行→ regedit
按下面路徑
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\OracleOraHome90TNSListener
找到OracleOraHome90TNSListener(我用的是Oracle9i 其他的版本的應該是OracleOraHomexxxTNSListener)

找到之后你會發現ImagePath關鍵值不存在了,創建它:(存在的話,點擊修改,修改方法在下文有介紹)
右鍵單擊,彈出菜單選擇新鍵(N)→字符串值(S)

將其命名為ImagePath
選中ImagePath點右鍵,選中修改:

在值中輸入你的Oracle安裝目錄\ora90(其他本對應的是oraxxx目錄)\bin\tnslsnr
如果是ORACLE 10G則安裝目錄為F:\oracle\product\10.1.0\Db_2\BIN\tnslsnr

確定后退出注冊表:
再在DOS命令下鍵入start
如果出現下面畫面,恭喜你,監聽器啟動成功:

關閉DOS,啟動你的程序進行測試,應該恢復正常了。
以上就是3中常見的引發The Network Adapter could not establish the connection 異常的原因
二、狀態: 失敗 -測試失敗: ORA-01031: insufficient privileges
權限不足。
經過測試,system,用一般權限登錄,可以正常登錄,只要是dba登錄,就登錄不上去,經過調查發現是
/usr/oracle/product/11.2.0/db_1/dbs目錄下缺少密碼文件:
orapworcl
orapwd file=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/ orapwbys3 password= oracle entries=3 force=y
ORA-01506: missing or illegal database name,Oracle 啟動實例所需最小化參數
以下實驗過程來自10.2.0.3
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for Linux: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
我們知道Oracle啟動實例尋找參數文件的順序為spfile<sid>.ora,spfile.ora,init<sid>.ora。那么Oracle啟動一個實例最小化參數是什么呢?以下就是實驗過程。
創建任意名字實例
啟動實例需要參數文件initzhoul.ora
SQL*Plus: Release 10.2.0.3.0 - Production on Sat Jan 9 13:55:35 2010
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/ora10g/oracle/product/10.2.0/db_1/dbs/initzhoul.ora'
SQL> exit
Disconnected
創建參數文件initzhoul.ora
再次嘗試啟動,提示需要參數db_name
ORA-01506: missing or illegal database name
添加db_name至參數文件
再次嘗試啟動zhoul實例,啟動成功
ORACLE instance started.
Total System Global Area 117440512 bytes
Fixed Size 1260384 bytes
Variable Size 58721440 bytes
Database Buffers 50331648 bytes
Redo Buffers 7127040 bytes
查看數據字典v$parameter,發現啟動該實例的只有db_name是非默認,也就是說只要只要設置參數db_name,即可啟動數據庫實例,其他參數均可采用初始值。
NAME
--------------------------------------------------------------------------------
db_name
觀察alert_zhoul.log,可以看到Oracle在啟動實例zhoul中調成了部分初始值。注意到undo retention自動調整被關閉。
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
background_core_dump string partial
[ora10g@mcprod log]$ cat alert_zhoul.log
Sat Jan 9 13:58:08 2010
Adjusting the default value of parameter parallel_max_servers
from 40 to 25 due to the value of parameter processes (40)
Sat Jan 9 13:58:08 2010
Starting ORACLE instance (normal)
LICENSE_MAX_SESSION = 0
LICENSE_SESSIONS_WARNING = 0
Sat Jan 9 13:58:19 2010
Adjusting the default value of parameter parallel_max_servers
from 40 to 25 due to the value of parameter processes (40)
Sat Jan 9 13:58:19 2010
Starting ORACLE instance (normal)
LICENSE_MAX_SESSION = 0
LICENSE_SESSIONS_WARNING = 0
Sat Jan 9 13:59:52 2010
Adjusting the default value of parameter parallel_max_servers
from 40 to 25 due to the value of parameter processes (40)
Sat Jan 9 13:59:52 2010
Starting ORACLE instance (normal)
LICENSE_MAX_SESSION = 0
LICENSE_SESSIONS_WARNING = 0
Sat Jan 9 14:01:25 2010
Adjusting the default value of parameter parallel_max_servers
from 40 to 25 due to the value of parameter processes (40)
Sat Jan 9 14:01:25 2010
Starting ORACLE instance (normal)
LICENSE_MAX_SESSION = 0
LICENSE_SESSIONS_WARNING = 0
Shared memory segment for instance monitoring created
Picked latch-free SCN scheme 2
Using LOG_ARCHIVE_DEST_1 parameter default value as /ora10g/oracle/product/10.2.0/db_1/dbs/arch
Autotune of undo retention is turned off.
LICENSE_MAX_USERS = 0
SYS auditing is disabled
ksdpec: called for event 13740 prior to event group initialization
Starting up ORACLE RDBMS Version: 10.2.0.3.0.
System parameters with non-default values:
db_name = zhoul
PMON started with pid=2, OS id=32133
PSP0 started with pid=3, OS id=32135
MMAN started with pid=4, OS id=32137
DBW0 started with pid=5, OS id=32139
LGWR started with pid=6, OS id=32141
CKPT started with pid=7, OS id=32143
SMON started with pid=8, OS id=32145
RECO started with pid=9, OS id=32147
MMON started with pid=10, OS id=32149
MMNL started with pid=11, OS id=32151