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.