LinuxUseODBCConnectOracle
因为工作需要,需要使用ODBC访问Oracle,下面是ODBC访问Oracle的具体配置
1.下载unixODBC和Oracle简易客户端软件包
1.1下载地址:
创新互联长期为超过千家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为民勤企业提供专业的网站设计制作、网站设计,民勤网站改版等技术服务。拥有十年丰富建站经验和众多成功案例,为您定制开发。
http://www.unixodbc.org/
1.1.1下载文件:
unixODBC-2.3.0.tar.gz
2 Oracle ODBC Driver
2.1下载地址:
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
2.1.1下载文件:
instantclient-sqlplus-linux.x64-12.2.0.1.0.zip instantclient-basic-linux.x64-12.2.0.1.0.zip instantclient-sdk-linux.x64-12.2.0.1.0.zip instantclient-jdbc-linux.x64-12.2.0.1.0.zip instantclient-odbc-linux.x64-12.2.0.1.0-2.zip instantclient-basiclite-linux.x64-12.2.0.1.0.zip instantclient-tools-linux.x64-12.2.0.1.0.zip
将这些软件包上传到/soft目录
3.安装unixODBC(root用户)
#cd /soft #tar xvf unixODBC-2.3.0.tar.gz #cd /soft/unixODBC-2.3.0 #./configure #make #make install
(默认是被安装到/usr/local)
4.安装Oracle ODBC(root用户)
#cd /soft/ #unzip instantclient-sqlplus-linux.x64-12.2.0.1.0.zip #unzip instantclient-basic-linux.x64-12.2.0.1.0.zip #unzip instantclient-sdk-linux.x64-12.2.0.1.0.zip #unzip instantclient-jdbc-linux.x64-12.2.0.1.0.zip #unzip instantclient-odbc-linux.x64-12.2.0.1.0-2.zip #unzip instantclient-basiclite-linux.x64-12.2.0.1.0.zip #unzip instantclient-tools-linux.x64-12.2.0.1.0.zip
[root@dmks instantclient_12_2]# ./odbc_update_ini.sh /usr/local *** ODBCINI environment variable not set,defaulting it to HOME directory!
更新操作完成后,会在/usr/local/etc/odbcinst.ini增加Oracle12C的驱动描述信息。
[root@dmks etc]# cat odbcinst.ini [DM7 ODBC DRIVER] Description = ODBC DRIVER FOR DM7 Driver = /dm_home/dmdbms/bin/libdodbc.so [Oracle 12c ODBC driver] Description = Oracle ODBC driver for Oracle 12c Driver = /soft/instantclient_12_2/libsqora.so.12.1 Setup = FileUsage = CPTimeout = CPReuse =
并且会在HOME目录下也就是/root,生成.odbc.ini文件,修改.odbc.ini文件
[root@dmks ~]# cat .odbc.ini [OracleODBC-12c] Application Attributes = T Attributes = W BatchAutocommitMode = IfAllSuccessful BindAsFLOAT = F CloseCursor = F DisableDPM = F DisableMTS = T Driver = Oracle 12c ODBC driver DSN = OracleODBC-12c EXECSchemaOpt = EXECSyntax = T Failover = T FailoverDelay = 10 FailoverRetryCount = 10 FetchBufferSize = 64000 ForceWCHAR = F Lobs = T Longs = T MaxLargeData = 0 MetadataIdDefault = F QueryTimeout = T ResultSets = T ServerName = shardcat 与tnsnames.ora文件中的服务器一致 SQLGetData extensions = F Translation DLL = Translation Option = 0 DisableRULEHint = T UserID = StatementCache=F CacheBufferSize=20 UseOCIDescribeAny=F SQLTranslateErrors=F MaxTokenSize=8192 AggregateSQLType=FLOAT
5.测试ODBC连接Oracle
[root@dmks ~]# isql OracleODBC-12c system xxzx7817600 -v +---------------------------------------+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +---------------------------------------+ SQL> select * from v$version; +---------------------------------------------------------------------------------+-----------------------------------------+ | BANNER | CON_ID | +---------------------------------------------------------------------------------+-----------------------------------------+ | Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production | 0 | | PL/SQL Release 12.2.0.1.0 - Production | 0 | | CORE 12.2.0.1.0 Production | 0 | TNS for Linux: Version 12.2.0.1.0 - Production | 0 | | NLSRTL Version 12.2.0.1.0 - Production | 0 | +---------------------------------------------------------------------------------+-----------------------------------------+
到此使用odbc连接Oracle的操作完成,还是很简单的。
分享名称:LinuxUseODBCConnectOracle
标题URL:http://myzitong.com/article/pisjco.html