1、检查是否安装了unixODBC
[root@a]# odbcinst -j
unixODBC 2.3.1
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /etc/odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
2、如未安装,进行安装
rpm -ivh unixODBC-2.2.14-1.x86_64.rpm
rmp -ivh unixODBC-devel-2.2.14-1.x86_64.rpm
3、安装CSDK, 路径是/opt/gbasecsdk
tar -xf clientsdt_x.x.x_x86_64.tar -C csdk
cd csdk;./installclientsdk -i silent -DLICENSE_ACCEPTED=TRUE -DUSER_INSTALL=/opt/gbasecsdk
4、编写实例的sqlhosts文件, 文件名称sqlhosts.odbc
gbase01 onsoctcp 192.168.1.10 9088
5、配置环境变量文件profile.odbc
export GBASEDBTDIR=/opt/gbasecsdk
export LD_LIBRARY_PATH=$GBASEDBTDIR/lib:$GBASEDBTDIR/lib/cli:$GBASEDBTDIR/lib/esql
export GBASEDBTSQLHOSTS=$GBASEDBTDIR/etc/sqlhosts.odbc
export ODBCINI=/etc/odbc.ini
执行环境文件,使环境变量在当前连接生效
source profile.odbc
6、修改CSDK安装路径下etc/odbc.ini 并替换到/etc/odbc.ini --示例见步骤9
7、修改CSDK安装路径下etc/odbcinst.ini 并替换到/etc/odbcinst.ini --示例见步骤10
8、使用isql连接数据库实例(gbaseserver1是DSN)
[root@localhost FTS_V1.0]# isql gbaseserver1 -v
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>
9、odbcinst.ini示例
# Example driver definitions
# Driver from the postgresql-odbc package
# Setup from the unixODBC package
[ODBC Drivers]
GBase ODBC DRIVER=Installed
[GBase ODBC Driver]
Driver=/opt/gbasecsdk/lib/cli/iclit09b.so
Setup=/opt/gbasecsdk/lib/cli/iclit09b.so
APILevel=1
ConnectFunctions=YYY
DriverODBCVer=03.51
FileUsage=0
SQLLevel=1
smProcessPerConnect=Y
10、odbc.ini示例
[ODBC Data Sources]
gbase72=GBase ODBC DRIVER
;
; Define ODBC Database Driver's Below - Driver Configuration Section
;
[gbaseserver1]
Driver=/opt/gbasecsdk/lib/cli/iclit09b.so
Description=GBase ODBC DRIVER
Database=wwdb
LogonID=gbasedbt
pwd=111111
Servername=gbase01
CLIENT_LOCALE=en_US.819
DB_LOCALE=en_US.819
;
; UNICODE connection Section
;
[ODBC]
;uncomment the below line for UNICODE connection
UNICODE=UCS-2
;
; Trace file Section
;
Trace=0
TraceFile=/tmp/odbctrace.out
InstallDir=/extra/informix
TRACEDLL=idmrs09a.so