dongye3917 2018-11-05 16:50
浏览 57
已采纳

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

I have a 32 bit Oracle DB (version 9i - 9.2.0.7.0), a 64 bit Mac and am trying to connect to it using go-oci8 with Go Lang (version go1.11.1 darwin/amd64).

I used SQL-Developer 4.0.2 to successfully connect to the DB and then enabled InstantClient connection through it using this tutorial. So I've got things running from the Oracle Client's side.

I'm using InstantClient Version 11.2.0.4.0 (32-bit) for MacOS (basic and SDK), I've used mainly this tutorial almost successfully. After everything, the error I'm getting is:

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:

And then a long stack of symbols. Basically the Go oci8 library is trying to use C (which is 64 bit) and tries to build 64 bit files, which will then be used by Go. If I try with the 64 bit version of InstantClient, I have no problems, but I get a "driver: bad connection" error which is because 64bit won't work to connect some reason.

I have no idea what to do to resole this issue - can I somehow force the build of 32 bit files while using go get -u -v github.com/mattn/go-oci8? Or somehow make the 64 bit InstantClient version connect to the old 32 bit Oracle DB?

Any kind of help on how to get this running would be much appreciated.

Edit: I've tried 10.2 Oracle Client, but I can't connect it with go-oci8 (I'm assuming it doesn't support it). The error I get is ../github.com/mattn/go-oci8/oci8.go:113:25: could not determine kind of name for C.OCI_SYSASM

Final edit for people who have the same problem (coming on to a very old Oracle Database) - you can't interface with the readily provided solutions using Go. The libraries listed to work with Oracle operate with Client versions 11.2 and up.

  • 写回答

1条回答 默认 最新

  • dtrpv60860 2018-11-05 19:05
    关注

    The architecture of the Oracle Client have to match so architecture of your application. I.e. if your Go Lang is 64-bit then the Oracle Client have to be also 64-bit. It does not matter whether the database is 32 or 64-bit.

    I think the main problem is, you cannot connect with an Oracle 11.2 Client to a (20 years old!) Oracle 9i database.

    Check Client / Server Interoperability Support Matrix for Different Oracle Versions (Doc ID 207303.1) for details.

    It says:

    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.

    You did not tell us which version of "Oracle 9i" your ar using.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵