Oracle11g遠程連接配置visualstudio2003
服務器端 配置:oracle11g R2 x64
1.設置監聽
a.啟動欄 -> 開始 -> 程序 -> Oracle-OraDb11g_home1 -> 配置和移植工具 -> Net Manager
b.Oracle Net 配置 -> 本地 -> 監聽程序 -> LISTENER ,查看是否有本地地址在監聽,沒有則添加,主機:"localhost",端口:1521,協議:TCP/IP
2.關閉所有防火牆(包括Window防火牆)
3.啟動TNS監聽服務:lsnrctl start (此程序LSNRCTL.exe位於oracle_path/product/11.2.0/dbhome_1/BIN目錄下
客戶端(Windows)
1.下載Instant Client for Microsoft Windows (32bit) 並安裝,地址: instant client下載
2.將instant client的安裝目錄加入path環境變量中
3.創建tnsnames.ora配置文件,內容格式如下:
[plain] view
plaincopy
-
# tnsnames.ora Network Configuration File: C:\e\orcldb\product\11.2.0\dbhome_1\NETWORK\ADMIN\tnsnames.ora
-
# Generated by Oracle configuration tools.
-
-
WSR =
-
(DESCRIPTION =
-
(ADDRESS_LIST =
-
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.112)(PORT = 1521))
-
)
-
(CONNECT_DATA =
-
(SERVICE_NAME = orcl)
-
)
-
)
-
-
ORACLR_CONNECTION_DATA =
-
(DESCRIPTION =
-
(ADDRESS_LIST =
-
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
-
)
-
(CONNECT_DATA =
-
(SID = CLRExtProc)
-
(PRESENTATION = RO)
-
)
-
)
-
-
LISTENER_ORCL =
-
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
-
-
ORCL =
-
(DESCRIPTION =
-
(ADDRESS_LIST =
-
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
-
)
-
(CONNECT_DATA =
-
(SERVER = DEDICATED)
-
(SERVICE_NAME = orcl)
-
)
-
)
比如此文件,我創建的TNS服務名為WRS,Oracle服務器地址為192.168.1.112,Oracle服務器監聽端口為1521,連接的Oracle數據庫名為orcl,可以按此格式進行替換。
4.添加TNS_ADMIN環境變量,指向創建的tnsnames.ora配置文件。
至此,配置已經完成,可以用pl/sql developer之類的工具連接遠程oracle數據庫,database即為添加的tns服務名(這裡為WSR)
如果要用odbc連接數據庫,還要添加odbc數據源,64位系統用C:\Windows\SysWOW64\odbcad32.exe,32位系統用C:\Windows\System32\odbcad32.exe