douqu8828 2014-09-07 23:08
浏览 47

将ODBC转到iSeries:SQL0104-无法成功翻译消息

I am attempting to use ODBC to query an IBM iSeries server (IBM i) using https://code.google.com/p/odbc/. I seem to think I had this working a while back when first testing but the server has since been updated, iSeries Access updated, and I am using Go 1.3.1

It seems to connect fine, but the query causes an error. I am guessing I am missing something with either the driver or the query being in the correct encoding but I am not sure how to address it or if it is perhaps a bug with the odbc library and I should open an issue there.

My code is as follows:

package main

import (
    _ "code.google.com/p/odbc"
    "database/sql"
    "fmt"
    "log"
)

func main() {
    db, err := sql.Open("odbc", `
        Driver=iSeries Access ODBC Driver;
        System=myhost;
        Uid=myuserid;
        Pwd=mypassword`)
    if err != nil {
        log.Fatal(err)
    }
    defer db.Close()

    rows, err := db.Query("SELECT 1 FROM sysibm.sysdummy1")
    if err != nil {
        log.Fatal(err)
    }

    var number int
    for rows.Next() {
        rows.Scan(&number)
    }
    fmt.Println(number)
}

When running the above, I am getting the following error message:

SQLPrepare: {42000} [IBM][System i Access ODBC Driver][DB2 for i5/OS]SQL0104 - Error message text unavailable.
Message can not be translated successfully.

Any ideas what is going wrong, what I can check, or how I can get this to work?

Update

I did a test on a Linux VM and this works with that exact code. I am able to use pyodbc with Python to connect on my Windows machine just fine using equivalent code, so this must be some sort of issue with this ODBC library on Windows. I think at this point unless there are other ideas, I'm going to try some other libraries or open a bug report with the library author.

  • 写回答

1条回答 默认 最新

  • dongxian6741 2014-09-08 15:42
    关注

    Just a shot in the dark - what is the system CCSID set to? DSPSYSVAL QCCSID. If it is 65535, that means the system language is 'binary - do not translate'. You might need to set the CCSID in your connection string if that's the case.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?