达梦数据库连接ODBC

1 odbc简介
ODBC为异构数据库访问提供统一接口,允许应用程序以SQL为数据存取标准,存取不同DBMS管理的数据;使应用程序直接操纵DB中的数据,免除随DB的改变而改变。
2 确认odbc版本
确认使用语句: odbcinst --version
在这里插入图片描述

如果没有安装odbc,需要下载如下安装包来安装。
官网下载地址:
http://ftp.unixodbc.org/
在这里插入图片描述

3 安装odbc
3.1 解压安装包

[root@DM8 unixODBC-2.3.9]# tar -zxvf unixODBC-2.3.9.tar.gz
3.2 odbc安装过程
3.2.1 安装前检查环境gcc/make编译器

[root@DM8 unixODBC-2.3.9]# rpm -qa | egrep ‘gcc|make’
cmake-3.12.1-5.ky10.x86_64
gcc-gfortran-7.3.0-20190804.h30.ky10.x86_64
automake-1.16.1-6.ky10.noarch
gcc-7.3.0-20190804.h30.ky10.x86_64
libgcc-7.3.0-20190804.h30.ky10.x86_64
make-4.2.1-15.ky10.x86_64
cmake-data-3.12.1-5.ky10.noarch
cmake-filesystem-3.12.1-5.ky10.x86_64
gcc-c+±7.3.0-20190804.h30.ky10.x86_64
cmake-rpm-macros-3.12.1-5.ky10.noarch

3.2.2 编译源码包并安装它
[root@DM8 unixODBC-2.3.9]# less INSTALL

  1. cd' to the directory containing the package's source code and type./configure’ to configure the package for your system. If you’re
    using csh' on an old version of System V, you might need to typesh ./configure’ instead to prevent csh' from trying to executeconfigure’ itself.

    Running `configure’ takes awhile. While running, it prints some
    messages telling which features it is checking for.

  2. Type `make’ to compile the package.

  3. Type `make install’ to install the programs and any data files and
    documentation.

  4. You can remove the program binaries and object files from the
    source code directory by typing make clean'. To also remove the files thatconfigure’ created (so you can compile the package for
    a different kind of computer), type make distclean'. There is also amake maintainer-clean’ target, but that is intended mainly
    for the package’s developers. If you use it, you may have to get
    all sorts of other programs in order to regenerate files that came
    with the distribution.

[root@DM8 home]# cd unixODBC-2.3.9/
[root@DM8 home]#./configure
[root@DM8 home]# make
[root@DM8 home]# make install

[root@DM8 unixODBC-2.3.9]# odbcinst --version
unixODBC 2.3.9
在这里插入图片描述

4 达梦数据库连接ODBC
[root@DM8 unixODBC-2.3.9]# odbcinst -j
unixODBC 2.3.9
DRIVERS…: /usr/local/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini
FILE DATA SOURCES…: /usr/local/etc/ODBCDataSources
USER DATA SOURCES…: /root/.odbc.ini
SQLULEN Size…: 8
SQLLEN Size…: 8
SQLSETPOSIROW Size.: 8

4.1 配置odbcinst.ini
指定驱动位置

在末尾加入如下内容:

cd /usr/local/etc
vi odbc.ini

[DM8 ODBC Driver]
Description = ODBC driver for DM8
Driver = /dmdba/dmdbms/bin/libdodbc.so

4.2 配置odbc.ini
数据源:加载驱动、主机、用户、密码
cd /usr/local/etc
vi odbc.ini

[dm8]
Description=DM ODBC DSN
Driver=DM8 ODBC Driver --与/etc/odbcinst.ini中的标题相同
SERVER=192.168.3.100
UID=SYSDBA
PWD=dmdba9999
TCP_PORT=5236

4.3 连接数据库

[dmdba@dca01 ~]$ isql dm8 -v

在这里插入图片描述

5 总结
首先检查odbc的版本,如果版本需要升级,根据INSTALL中的要求安装就可以了。连接odbc就是需要配置2个文件,这两个配置文件的位置由odbcinst -j里面指定了,不能改变。odbc.ini文件指定了需要连接的数据库的用户名和密码,这些信息如果填错就会报错如下:
在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值