unixODBC,Golang,Informix,Ubuntu

huangapple go评论74阅读模式
英文:

unixOBC, Golang, Informix, Ubuntu

问题

我目前正在尝试ping一个Informix数据库,

db, err := sql.Open("odbc","DNS=x")

if err != nil { 
  log.Fatal(err)
}

if err := db.Ping(); err != nil {
  log.Printf("ping失败 %#v", err)
} else {
  log.Printf("ping成功")
}

defer db.Close()

我得到了以下错误信息...

State: "H", NativeError:"-11060", Message:"[unixODBC]["

isql正常工作,但是通过alexbrainman的odbc驱动程序没有成功。在Windows上也正常工作。任何帮助将不胜感激。

英文:

I'm currently trying to ping an informix database,

db, err := sql.Open("odbc","DNS=x")

if err != ni { 
  log.Fatal(err)
}

if err := db.Ping(); err != nil {
  log.Printf("ping failed %#v", err)
} else {
  log.Printf("ping success")
}

defer db.Close()

and I get an error like this...

State: "H", NativeError:"-11060", Message:"[unixODBC]["

isql works fine, but I'm getting no luck via the alexbrainman odbc driver. Windows also works fine too. Any help would be appreciated.

答案1

得分: 0

这是一个配置问题。根据Informix文档,odbc.ini必须使用UCS-2或UCS-4进行编码。这是unixODBC使用配置文件的方式。

在odbc.ini的末尾附近,有一个[ODBC]部分,请取消注释UNICODE选项,如下所示:

;
; UNICODE连接部分
;
[ODBC]
;取消下面一行的注释以进行UNICODE连接
UNICODE=UCS-2
;
; 跟踪文件部分
;
Trace=0
TraceFile=/tmp/odbctrace.out
InstallDir=/extra/informix
TRACEDLL=idmrs09a.so
英文:

This turns out to be a configuration problem. Appearently, odbc.ini has to be encoded in UCS-2 or UCS-4 according to the informix documentation. This turns out to be how the unixODBC consumes the configuration file.

nearing the end of odbc.ini, there is an [ODBC] section, uncomment the UNICODE option like so

;
; 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

huangapple
  • 本文由 发表于 2017年4月7日 07:46:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/43267501.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定