unixODBC,Golang,Informix,Ubuntu

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

unixOBC, Golang, Informix, Ubuntu

问题

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

  1. db, err := sql.Open("odbc","DNS=x")
  2. if err != nil {
  3. log.Fatal(err)
  4. }
  5. if err := db.Ping(); err != nil {
  6. log.Printf("ping失败 %#v", err)
  7. } else {
  8. log.Printf("ping成功")
  9. }
  10. defer db.Close()

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

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

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

英文:

I'm currently trying to ping an informix database,

  1. db, err := sql.Open("odbc","DNS=x")
  2. if err != ni {
  3. log.Fatal(err)
  4. }
  5. if err := db.Ping(); err != nil {
  6. log.Printf("ping failed %#v", err)
  7. } else {
  8. log.Printf("ping success")
  9. }
  10. defer db.Close()

and I get an error like this...

  1. 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选项,如下所示:

  1. ;
  2. ; UNICODE连接部分
  3. ;
  4. [ODBC]
  5. ;取消下面一行的注释以进行UNICODE连接
  6. UNICODE=UCS-2
  7. ;
  8. ; 跟踪文件部分
  9. ;
  10. Trace=0
  11. TraceFile=/tmp/odbctrace.out
  12. InstallDir=/extra/informix
  13. 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

  1. ;
  2. ; UNICODE connection Section
  3. ;
  4. [ODBC]
  5. ;uncomment the below line for UNICODE connection
  6. UNICODE=UCS-2
  7. ;
  8. ; Trace file Section
  9. ;
  10. Trace=0
  11. TraceFile=/tmp/odbctrace.out
  12. InstallDir=/extra/informix
  13. 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:

确定