• golang access oracle


    1. linux下先装好

    http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

    rpm -ivh oracle-instantclient11.2-basic-12.1.0.2.0.x86_64.rpm
    rpm -ivh oracle-instantclient11.2-sqlplus-12.1.0.2.0.x86_64.rpm

    export ORACLE_HOME=/usr/lib/oracle/12.1/client64
    export PATH=$ORACLE_HOME/bin:$PATH
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib

    sudo vi /etc/ld.so.conf.d/oracle.conf && sudo chmod o+r /etc/ld.so.conf.d/oracle.conf
    /usr/lib/oracle/12.1/client64/lib/

     sudo apt-get install libaio1

    sqlplus "scott/xxx@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.11.149)(PORT=1521))(CONNECT_DATA=(SID=orcl)))"

    #hostname  结果要在/etc/hosts中有

    2. 

    sudo ln -s /usr/include/oracle/12.1/client64 $ORACLE_HOME/include
    export PKG_CONFIG_PATH=~/pkg_config_path
    vi ~/pkg_config_path/oci8.pc

    prefix=/usr/lib/oracle/12.1/client64
    exec_prefix=${prefix}
    libdir=/usr/lib/oracle/12.1/client64/lib
    includedir=/usr/include/oracle/12.1/client64

    glib_genmarshal=glib-genmarshal
    gobject_query=gobject-query
    glib_mkenums=glib-mkenums

    Name: oci8
    Description: oci8 library
    Libs: -L${libdir} -lclntsh
    Cflags: -I${includedir}
    Version: 12.1

    oci8.pc view  https://github.com/mattn/go-oci8

    go get  github.com/mattn/go-oci8

    3. test

    https://raw.githubusercontent.com/wendal/go-oci8/master/example/oracle.go

     key:

    db, err := sql.Open("oci8", "scott/tiger@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.11.149)(PORT=1521))(CONNECT_DATA=(SID=orcl)))")

        https://help.ubuntu.com/community/Oracle%20Instant%20Client

  • 相关阅读:
    c#9
    Jmeter--自己写并发压测脚本一定会遇到的类
    Jmeter从数据库获取测试数据, 作为下一个接口参数方法
    Jmeter-从数据库中获取数据并作为变量传输
    Java文件操作
    Java读取文件
    Java字符串处理——String类常用方法
    Eclipse导出可执行jar包步骤
    批处理常用DOS命令之for简单 002
    批处理常用DOS命令之for简单 001
  • 原文地址:https://www.cnblogs.com/anjuncc/p/5797666.html
Copyright © 2020-2023  润新知