Connecting to Oracle Database Using Server Side Sw

2019-08-01 02:21发布

Is it possible yet to connect to an Oracle Database using Swift (raw or a Swift framework) on Linux? What I have done is tried to build a Docker VM, install the Oracle binaries, add the OCILIB package and then connect [tried] using a package called SwiftOracle, which seems unsupported (lots of build issues) and just exposes the OCILIB C code to Swift using a module map and wrapper.

I tried this using the Kitura framework and none of this seemed to work - Xcode can't compile because it isn't unable to either find the C library or create the module.

Here are the steps that I have tried to no avail:

Build Docker VM (which includes Oracle binaries): https://github.com/wnameless/docker-oracle-xe-11g

Download and install OCILIB: https://github.com/vrogier/ocilib

Add SwiftOracle package, fix build issues and try to build.

1条回答
我命由我不由天
2楼-- · 2019-08-01 02:55

you can use the following method to connect to oracle database: ( This was possible by the help of vapor community.)

-----to make oracle driver work, I have Tied this method in Ubuntu------------- -- oracle client need to be installed such that the header and library path can be defined, you can get these from oracle website.

oracle-instantclinet*-basic-*.rpm
oracle-instantclinet*-devel-*.rpm
oracle-instantclinet*-sqlplus-*.rpm

--install thus downloaded package using following command

sudo alien -i oracle-instantclinet*-basic-*.rpm
sudo alien -i oracle-instantclinet*-devel-*.rpm
sudo alien -i oracle-instantclinet*-sqlplus-*.rpm

-- Install libaio1 in ubuntu

sudo apt install libaio1

-- this path should be in ~/.bashrc

#oracle home and library path
export ORACLE_HOME=/usr/lib/oracle/12.2/client64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/oracle/12.2/client64/lib:/usr/local/lib

--download OCILIB library from Github git clone https://github.com/vrogier/ocilib.git ( or download the latest version / tested on ocilib 4.5.2 ) -- extract ocilib file cd to ocilib folder, configure make and make install

    tar -zxf ocilib-4.5.2-gnu.tar.gz
    cd ocilib-4.5.2
    ./configure --with-oracle-headers-path=/usr/include/oracle/12.2/client64/ --with-oracle-lib-path=/usr/lib/oracle/12.2/client64/lib CFLAGS="-O2 -m64"
    make
    sudo make install

-- use this configuration if you need to deal with unicodes, generally you don't need this

./configure --with-oracle-headers-path=/usr/include/oracle/12.2/client64/ --with-oracle-lib-path=/usr/lib/oracle/12.2/client64/lib --with-oracle-charset=wide CFLAGS="-O2 -m64"

-- The above method installs OCILIB in your machine. -- To user OCILIB library in your Vapor project Include the following in you Package.swift file

    // swift-tools-version:4.0
    import PackageDescription

    let package = Package(
        name: "myAPIProject",
        dependencies: [
            //                                                                     
查看更多
登录 后发表回答