Golang using Oracle driver package to access Oracle DB

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed. 1. First download the package file on GitHub https://github.com/tgulacsi/goracle

2. Set the compilation environment does not set the compilation environment, otherwise go build will appear: # github.com/tgulacsi/goracle/oraclesrc/github.com/tgulacsi/goracle/oracle/ Connection.go:23:17:error:oci.h:no such file or Directorysrc/github.com/tgulacsi/goracle/oracle/connection.go : 25:16:error:xa.h:no such file or directory
He gives the compiler environment script, but looks more complex, in fact, two sentences, set up 2 CGO flag is OK. Exportcgo_cflags=-i/opt/oracle/product/orahome/rdbms/publicexport Cgo_ldflags=-l/opt/oracle/product/orahome/lib

3. Run your program:
Run the time to still error: $ $ goprom xxxx Xxxxxgoprom : Error while loading Sharedlibraries:libclntsh.so.11.1:cannot open shared object File:nosuch file or directory
This time look at the Oracle user's env, add the variables of the dynamic library: Ld_library_path=/opt/oracle/product/orahome/lib:/lib:/usr/lib:/usr/local/lib
4. Connect to the database. But when the runtime connects to Oracle it's time to get an error: I1225 23:23:06 11474 runmysqlsql.go:74] connectusing:oraadm/passw0rd@gooradb: @Unable To acquire Oracleenvironment Handle-1073741818:other
Switch to Oracle to run it. However, it is still not possible to add the environment variables of the Oracle user to your users.
Spit it out, how do I feel Oracle's installation configuration is more difficult than DB2.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.