Go lang 连接到 Oracle 9i(使用 go-oci8)

Go lang connect to Oracle 9i (using go-oci8)

我有一个 32 位 Oracle 数据库(版本 9i - 9.2.0.7.0),一个 64 位 Mac,我正在尝试使用 go-oci8 和 Go Lang(版本 go1)连接到它.11.1 darwin/amd64).

我使用了 SQL-Developer 4.0.2 to successfully connect to the DB and then enabled InstantClient connection through it using this 教程。所以我从 Oracle 客户端那里得到了一些东西 运行。

我正在为 MacOS(基本和 SDK)使用 InstantClient 版本 11.2.0.4.0(32 位),我主要使用 this 教程几乎成功地。毕竟,我得到的错误是:

github.com/mattn/go-oci8 ld: warning: ignoring file /Users/myusername/Downloads/instantclient_11_2/libclntsh.dylib, file was built for i386 which is not the architecture being linked (x86_64): /Users/myusername/Downloads/instantclient_11_2/libclntsh.dylib Undefined symbols for architecture x86_64:

然后是一长串符号。基本上,Go oci8 库尝试使用 C(64 位)并尝试构建 64 位文件,然后 Go 将使用这些文件。如果我尝试使用 64 位版本的 InstantClient,我没有任何问题,但我收到 "driver: bad connection" 错误,这是因为 64 位无法连接某些原因。

我不知道如何解决这个问题 - 我可以在使用 go get -u -v github.com/mattn/go-oci8 时以某种方式强制构建 32 位文件吗?或者以某种方式使 64 位 InstantClient 版本连接到旧的 32 位 Oracle 数据库?

任何有关如何获得此 运行 的帮助将不胜感激。

编辑:我试过 10.2 Oracle Client,但我无法将它与 go-oci8 连接(我假设它不支持它)。我得到的错误是 ../github.com/mattn/go-oci8/oci8.go:113:25: could not determine kind of name for C.OCI_SYSASM

对遇到同样问题的人的最终编辑(进入一个非常古老的 Oracle 数据库)- 您无法使用 Go 与现成的解决方案进行交互。列出的与 Oracle 一起使用的库与客户端版本 11.2 及更高版本一起运行。

Oracle 客户端的体系结构必须与您的应用程序的体系结构相匹配。 IE。如果您的 Go Lang 是 64 位的,那么 Oracle 客户端也必须是 64 位的。数据库是 32 位还是 64 位并不重要。

我认为主要问题是,您无法使用 Oracle 11.2 客户端连接到(20 岁!)Oracle 9i 数据库。

查看 Client / Server Interoperability Support Matrix for Different Oracle Versions (Doc ID 207303.1) 了解详情。

它说:

For connections between 10.2 (or higher) and 9.2 the 9.2 end MUST be at 9.2.0.4 or higher. Connections between 10.2 (or higher) and 9.2.0.1, 9.2.0.2 or 9.2.0.3 have never been supported.

您没有告诉我们您使用的 "Oracle 9i" 是哪个版本。