Linux 系统调用ODBC驱动,前提条件是操作系统安装unixODBC环境。
1. 下载unixODBC
What is ODBC?
ODBC is an open specification for providing application developers with a predictable API with which to access Data Sources. Data Sources include SQL Servers and any Data Source with an ODBC Driver.
2. 将附件unixODBC-2.3.9.tar.gz上传到/usr/local下,执行安装。
|
[root@rhel7 local]# tar -zxvf unixODBC-2.3.9.tar.gz [root@rhel7 local]# cd unixODBC-2.3.9/ [root@rhel7 unixODBC-2.3.9]# ./configure [root@rhel7 unixODBC-2.3.9]# make [root@rhel7 unixODBC-2.3.9]# make install |
3. 查看操作系统上查看ODBC版本
|
[dmdba@rhel7 ~]$ odbc_config --version 2.3.9 |
4. 查看ODBC配置文件存放的位置
|
[dmdba@rhel7 ~]$ odbc_config --odbcini /usr/local/etc/odbc.ini [dmdba@rhel7 ~]$ odbc_config --odbcinstini /usr/local/etc/odbcinst.ini |
5. 修改odbc.ini文件
|
[root@rhel7 ~]# vi /usr/local/etc/odbc.ini [dm] Description = DM ODBC DSN Driver = DM8 ODBC DRIVER SERVER = localhost UID = SYSDBA PWD = SYSDBA TCP_PORT = 5236 |
6. 修改odbcinst.ini文件
|
[root@rhel7 ~]# vi /usr/local/etc/odbcinst.ini [ DM8 ODBC DRIVER] Description = ODBC DRIVER FOR DM8 Driver = /dm8/bin/libdodbc.so |
7. 测试连接
|
[dmdba@rhel7 ~]$ isql dm +---------------------------------------+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +---------------------------------------+ SQL> |