go 通過odbc獲取kingbase資料庫資訊

2021-10-13 07:41:49 字數 4715 閱讀 7039

[kingbasees 8 odbc driver]

description=kingbasees 8 odbc driver for linux

driver=/xx/xx/xx/kingbase-odbc-linux-x86_64/kdbodbcw.so

setup =/xx/xx/xx/kingbase-odbc-linux-x86_64/kdbodbcw.so

debug=0

commlog=1

usagecount=1

odbc.ini配置如下:servername,username,password根據實際情況配置

[kingbase]

description             = kingbasees

driver                  = kingbasees 8 odbc driver

trace                   = no

tracefile               =

database                = test

servername              = ip

username                = system

password                = 123456

port                    = 54321

readonly                = no

rowversioning           = no

showsystemtables        = no

showoidcolumn           = no

fakeoidindex            = no

connsettings            =

配置好後,執行 isql  kingbase

報錯結果isql]error: could not sqlconnect

cd /xx/xx/xx/kingbase-odbc-linux-x86_64

執行:ldd kdbodbcw.so

linux-vdso.so.1 =>  (0x00007fff2e575000)

libkci.so.5 => /usr/local/zhx/kingbase-odbc-linux-x86_64/./libkci.so.5 (0x00007f7abf3ca000)

libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f7abf1ae000)

libodbcinst.so.2 => /lib64/libodbcinst.so.2 (0x00007f7abef9c000)

libc.so.6 => /lib64/libc.so.6 (0x00007f7abebce000)

libssl.so.6 => not found

libcrypto.so.6 => not found

libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f7abe997000)

/lib64/ld-linux-x86-64.so.2 (0x00007f7abf878000)

libltdl.so.7 => /lib64/libltdl.so.7 (0x00007f7abe78d000)

libdl.so.2 => /lib64/libdl.so.2 (0x00007f7abe589000)

libfreebl3.so => /lib64/libfreebl3.so (0x00007f7abe386000)

到 /usr/lib64目錄下,檢視是否有libssl.so和libcrypto.so

ll /usr/lib64/libssl.so*

結果如下:

lrwxrwxrwx. 1 root root     16 12月 28 15:21 /usr/lib64/libssl.so.10 -> libssl.so.1.0.2k

-rwxr-xr-x. 1 root root 470376 12月 17 05:24 /usr/lib64/libssl.so.1.0.2k

建立軟鏈結

ln -s /usr/lib64/libssl.so.1.0.2k libssl.so.6

同樣的操作,為libcrypto.so.6建立軟鏈結

ln -s /usr/lib64/libcrypto.so.1.0.2k libcrypto.so.6

再次執行 ldd kdbodbcw.so

結果如下:

linux-vdso.so.1 =>  (0x00007ffc4f181000)

libkci.so.5 => /usr/local/zhx/kingbase-odbc-linux-x86_64/././libkci.so.5 (0x00007f4bbfd79000)

libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f4bbfb5d000)

libodbcinst.so.2 => /lib64/libodbcinst.so.2 (0x00007f4bbf94b000)

libc.so.6 => /lib64/libc.so.6 (0x00007f4bbf57d000)

libssl.so.6 => /lib64/libssl.so.6 (0x00007f4bbf30b000)

libcrypto.so.6 => /lib64/libcrypto.so.6 (0x00007f4bbeea8000)

libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f4bbec71000)

/lib64/ld-linux-x86-64.so.2 (0x00007f4bc0227000)

libltdl.so.7 => /lib64/libltdl.so.7 (0x00007f4bbea67000)

libdl.so.2 => /lib64/libdl.so.2 (0x00007f4bbe863000)

libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f4bbe616000)

libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f4bbe32d000)

libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f4bbe129000)

libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f4bbdef6000)

libz.so.1 => /lib64/libz.so.1 (0x00007f4bbdce0000)

libfreebl3.so => /lib64/libfreebl3.so (0x00007f4bbdadd000)

libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f4bbd8cd000)

libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f4bbd6c9000)

libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f4bbd4af000)

libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f4bbd288000)

libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f4bbd026000)

證明依賴已經安裝完畢,執行isql  kingbase

+---------------------------------------+

| connected!                            |

|                                       |

| sql-statement                         |

| help [tablename]                      |

| quit                                  |

|                                       |

+---------------------------------------+

證明連線上資料庫了,可進行程式連線

go**如下,查詢kingbase引數資訊

package main

import (

"fmt"

"database/sql"

_ "odbc/driver"

)func main()

defer db.close()

//rows, err := db.query("select age,name from user ")

//for rows.next()

//// fmt.printf("%d\t%s\n", age, name)

//}rows2, err := db.query("show all")

for rows2.next()

fmt.printf("%s\t\t\t\t\t\t\t\t\t%-5s\n", name, setting)

}rows2.close()

fmt.printf("\ngo odbc測試程式結束執行.\n")

}

Debian通過ODBC連線Mysql

被網上的原始碼安裝坑了2天,積累了不少經驗,可惜還是未能成功。總結出乙個道理,新事物一定要看官方與非官方的api。下面是在debian系統上使用odbc連線mysql的操作步驟,需要的童鞋請拿走 前言 本次操作基於純淨debian作業系統,因為我才重灌了。1 安裝unixodbc 網上都說原始碼安裝...

Linux下通過ODBC連線SQL Server

一 測試環境 作業系統 fedora 8 資料庫 sqlserver2000 installed in windows xp professional,資料庫有使用者sa,密碼是syth7777,資料庫檔案是qjkzdb 注意 1 ms從來沒有提供過sqlserver for linux,所以也不要...

Qt通過ODBC讀取excel檔案

之前替學校考試科用c builder做過乙個小的資料庫工具,處理excel 用的,現在想轉換到qt平台下來,在網上搜了搜有一些利用obdc讀取xls檔案的教程 試了一下可以用,但是轉換到圖形介面中遇到點問題,在用qsqltablemodel類的settable 方法使無法讀取到 sheet1 將其換...