我正在尝试从 Windows(64 位 Go,32 位客户端)连接到 Oracle DB
我已经提出了这个问题,但我对 Go 完全陌生,所以我对他建议的配置一无所知。
我安装了多个客户端,例如:
1. `code.google.com\p\odbc`
2. `github.com\mattn\go-oci8`
我试图创建该oci8.pc文件,但似乎是错误的。
prefix=/devel/target/1.0
exec_prefix=${prefix}
libdir=C:/oracle/instantclient_12_1/sdk/lib/msvc
includedir=C:/oracle/instantclient_12_1/sdk/include
oralib=C:/oracle/instantclient_12_1/sdk/lib/msvc
orainclude=C:/oracle/instantclient_12_1/sdk/include
gcclib=C:/TDM-GCC-64/lib
gccinclude=C:/TDM-GCC-64/include
glib_genmarshal=glib-genmarshal
gobject_query=gobject-query
glib_mkenums=glib-mkenums
Name: oci8
Version: 12.1
Description: oci8 library
Libs: -L${oralib} -L${gcclib} -loci
Libs.private:
Cflags: -I${orainclude} -I${gccinclude}
当我运行以下代码时,出现错误:
// TestDB
package main
import (
"github.com/odbc"
)
func main() {
conn, _ := odbc.Connect("DSN=lnxcepd1db01.XXXXXX.com:51521*CBPDEV;UID=XXXXX;PWD=XXXXX")
defer conn.Close()
stmt, _ := conn.Prepare("select * from XXXXX where XXXX = ?")
defer stmt.Close()
stmt.Execute("100044")
rows, _ := stmt.FetchAll()
for i, row := range rows {
println(i, row)
}
}
错误:
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x8 pc=0x43c3a6]
goroutine 1 [running]:
github.com/odbc.(*Connection).Close(0x0, 0x45)
C:/Go/UDL/src/github.com/odbc/odbc.go:263 +0x26
github.com/odbc.(*Connection).newStmt(0x0, 0x36, 0xc0820120e0)
C:/Go/UDL/src/github.com/odbc/odbc.go:152 +0x50
github.com/odbc.(*Connection).Prepare(0x0, 0x51cf70, 0x36, 0x0, 0x0, 0x0, 0xc082005e90, 0x9d6eb0)
C:/Go/UDL/src/github.com/odbc/odbc.go:162 +0x51
main.main()
C:/Go/My Codes/new/TestDB.go:12 +0xc4
goroutine 17 [syscall, locked to thread]:
runtime.goexit()
c:/go/src/runtime/asm_amd64.s:2232 +0x1
我错过了什么吗?如果有人能指出我正确的方向,我将非常感激。
猛跑小猪
相关分类