程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> 經由過程HSODBC拜訪mysql的完成步調

經由過程HSODBC拜訪mysql的完成步調

編輯:MySQL綜合教程

經由過程HSODBC拜訪mysql的完成步調。本站提示廣大學習愛好者:(經由過程HSODBC拜訪mysql的完成步調)文章只能為提供參考,不一定能成為您想要的結果。以下是經由過程HSODBC拜訪mysql的完成步調正文


1、情況
OS:Linux myhostname 2.6.9-42.ELsmp #1 SMP Sat Aug 12 09:39:11 CDT 2006 i686 i686 i386 GNU/Linux
CentOS release 4.4 (Final)
Oracle:Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod,數據庫曾經裝置好
mysql:5.1.34-community for windows

2、裝置設置裝備擺設
1. 裝置unixODBC,用root用戶
rpm -Uvh unixODBC-2.2.12-1.el4s1.1.i386.rpm
2. 裝置mysql ODBC,用root用戶
rpm -Uvh mysql-connector-odbc-5.1.5-0.i386.rpm
3. 裝置oracle gateway,用oracle用戶
我裝的是10201_gateways_linux32.zip
unzip 10201_gateways_linux32.zip
cd gateways
./runInstaller
裝置辦法和oracle db 軟件一樣,我把gateway和db裝一路了,共用一個OracleHOME
4. 設置裝備擺設/etc/odbc.ini
[DSName]
Driver =/usr/lib/libmyodbc5.so
Description =MySQL
Server =xxx.xxx.xxx.xxx
Port =3306
User =root
UID =root
Password = mypass
Database =mysqldbname
Option =3
Socket =
charset =utf8
測試ODBC
isql -v DSName root mypass
5. 設置裝備擺設$ORACLE_HOME/hs/admin/initDSName.ora
HS_FDS_CONNECT_INFO = DSName
HS_FDS_TRACE_LEVEL = 0
HS_FDS_SHAREABLE_NAME = /usr/lib/libmyodbc5.so
6. 設置裝備擺設listener.ora,加白色部門
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /usr/u01/app/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = BOSS)
(ORACLE_HOME = /usr/u01/app/oracle/product/10.2.0/db_1)
(SID_NAME = BOSS)
)
(SID_DESC =
(SID_NAME = phpcms)
(ORACLE_HOME = /usr/u01/app/oracle/product/10.2.0/db_1)
(PROGRAM = hsodbc)
)
)
7. 設置裝備擺設tnsnames.ora,添加
DSName =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.125)(PORT = 1521))
)
(CONNECT_DATA = (SERVICE_NAME = DSName))
(HS = OK)
)
8. 重啟監聽器並測試
lsnrctl reload
lsnrctl service
Service "DSName" has 1 instance(s).
Instance "DSName", status UNKNOWN, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:3 refused:0
LOCAL SERVER
The command completed successfully
tnsping DSName
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.125)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = DSName)) (HS = OK))
OK (0 msec)
9. 樹立dblink
CREATE PUBLIC DATABASE LINK linkname
CONNECT TO "root"
IDENTIFIED BY <PWD>
USING 'DSName';
10. 測試
select "name" from t1@linkname;
3、遺留成績
1. 字符集成績,最好oracle和mysql是utf8,不然中文有成績
2. text字段會報錯:
select "textcol" from t1@linkname;
ORA-28500: 銜接 ORACLE 到非 Oracle 體系時前往此信息:
[Generic Connectivity Using ODBC][MySQL][ODBC 5.1 Driver][mysqld-5.1.34-community]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"t1" WHERE "id"=1' at line 1 (SQL State: 37000; SQL Code: 1064)
ORA-02063: 緊接著 2 lines (起自 DSName)
原來想用datadirect的mysql ODBC嘗嘗,可只支撐mysql enterprise版本,其實欠好找,今後無機會再說吧。
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved