Skip to content

Commit

Permalink
Closes pull request 54
Browse files Browse the repository at this point in the history
  • Loading branch information
Raymond Feng authored and joeferner committed Aug 12, 2013
1 parent c00b157 commit b22b009
Show file tree
Hide file tree
Showing 10 changed files with 437 additions and 143 deletions.
120 changes: 98 additions & 22 deletions README.md
Original file line number Original file line Diff line number Diff line change
@@ -1,25 +1,101 @@
# Install # Install
* Install the Oracle Instant Client:
* Download the [Instant Client Package](http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html): both "Basic Lite" and "SDK". You need to download and install [Oracle instant client](http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html) from following links:
* Extract both the Basic Lite and the SDK zip files to `/opt/instantclient/` (Linux/OS X) or `C:\oracle\instantclient\` (Windows)
* or put them wherever you want and set the environment variables `OCI_INCLUDE_DIR` (to the sdk/include) and `OCI_LIB_DIR` (to the directory containing libocci.so.11.1 on Linux/OS X, or oraocci11.lib on Windows). http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
* Linux: add the shared object files to the ld cache:

1. Instant Client Package - Basic or Basic Lite: All files required to run OCI, OCCI, and JDBC-OCI applications
```bash 2. Instant Client Package - SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client
# Replace /opt/instantclient/ with wherever you extracted the Basic Lite files to
echo '/opt/instantclient/' | sudo tee -a /etc/ld.so.conf.d/moo.conf For Windows, please make sure 12_1 version is used.
sudo ldconfig
``` **Please make sure you download the correct packages for your system architecture, such as 64 bit vs 32 bit**
* Create the symbolic links: **Unzip the files 1 and 2 into the same directory, such as /opt/instantclient\_11\_2 or c:\instantclient\_12\_1**


```bash On MacOS or Linux:
cd /opt/instantclient/
sudo ln -s libclntsh.so.11.1 libclntsh.so 1. Set up the following environment variables
sudo ln -s libocci.so.11.1 libocci.so
``` MacOS/Linux:
* Finally install using Node Package Manager (npm):

```
`npm install oracle` export OCI_HOME=<directory of Oracle instant client>
export OCI_LIB_DIR=$OCI_HOME
export OCI_INCLUDE_DIR=$OCI_HOME/sdk/include
```

2. Create the following symbolic links

MacOS:

```
cd $OCI_LIB_DIR
ln -s libclntsh.dylib.11.1 libclntsh.dylib
ln -s libocci.dylib.11.1 libocci.dylib
```

Linux:

```
cd $OCI_LIB_DIR
ln -s libclntsh.so.11.1 libclntsh.so
ln -s libocci.so.11.1 libocci.so
```

`libaio` library is required on Linux systems:

* On Unbuntu/Debian

```
sudo apt-get install libaio1
```

* On Fedora/CentOS/RHEL

```
sudo yum install libaio
```

3. Configure the dynamic library path

MacOS:

```
export DYLD_LIBRARY_PATH=$OCI_LIB_DIR
```

Linux:

Add the shared object files to the ld cache:

```
# Replace /opt/instantclient_11_2/ with wherever you extracted the Basic Lite files to
echo '/opt/instantclient_11_2/' | sudo tee -a /etc/ld.so.conf.d/oracle_instant_client.conf
sudo ldconfig
```

On Windows, you need to set the environment variables:

If you have VisualStudio 2012 installed,

```
OCI_INCLUDE_DIR=C:\instantclient_12_1\sdk\include
OCI_LIB_DIR=C:\instantclient_12_1\sdk\lib\msvc\vc11
Path=...;c:\instantclient_12_1\vc11;c:\instantclient_12_1
```

**Please make sure c:\instantclient_12_1\vc11 comes before c:\instantclient_12_1**

If you have VisualStudio 2010 installed,

```
OCI_INCLUDE_DIR=C:\instantclient_12_1\sdk\include
OCI_LIB_DIR=C:\instantclient_12_1\sdk\lib\msvc\vc10
Path=...;c:\instantclient_12_1\vc10;c:\instantclient_12_1
```

**Please make sure c:\instantclient_12_1\vc10 comes before c:\instantclient_12_1**



# Examples # Examples


Expand Down Expand Up @@ -66,7 +142,7 @@ To access a table you could then use:
```javascript ```javascript
oracle.connect(connData, function(err, connection) { oracle.connect(connData, function(err, connection) {


connection.setAutoCommit(true); or just the shortcut as declared in your `tnsnames.ora`:


// selecting rows // selecting rows
connection.execute("SELECT * FROM person", [], function(err, results) { connection.execute("SELECT * FROM person", [], function(err, results) {
Expand Down
31 changes: 27 additions & 4 deletions binding.gyp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,23 +10,45 @@
["OS=='mac'", { ["OS=='mac'", {
"xcode_settings": { "xcode_settings": {
"GCC_ENABLE_CPP_EXCEPTIONS": "YES" "GCC_ENABLE_CPP_EXCEPTIONS": "YES"
} },
}],
["OS!='win'", {
"variables": { "variables": {
"oci_include_dir%": "<!(if [ -z $OCI_INCLUDE_DIR ]; then echo \"/opt/instantclient/sdk/include/\"; else echo $OCI_INCLUDE_DIR; fi)", "oci_include_dir%": "<!(if [ -z $OCI_INCLUDE_DIR ]; then echo \"/opt/instantclient/sdk/include/\"; else echo $OCI_INCLUDE_DIR; fi)",
"oci_lib_dir%": "<!(if [ -z $OCI_LIB_DIR ]; then echo \"/opt/instantclient/\"; else echo $OCI_LIB_DIR; fi)", "oci_lib_dir%": "<!(if [ -z $OCI_LIB_DIR ]; then echo \"/opt/instantclient/\"; else echo $OCI_LIB_DIR; fi)",
}, },
"libraries": [ "-locci", "-lclntsh", "-lnnz11" ], "libraries": [ "-locci", "-lclntsh", "-lnnz11" ],
"link_settings": {"libraries": [ '-L<(oci_lib_dir)'] } "link_settings": {"libraries": [ '-L<(oci_lib_dir)'] }
}], }],
["OS=='linux'", {
"variables": {
"oci_include_dir%": "<!(if [ -z $OCI_INCLUDE_DIR ]; then echo \"/opt/instantclient/sdk/include/\"; else echo $OCI_INCLUDE_DIR; fi)",
"oci_lib_dir%": "<!(if [ -z $OCI_LIB_DIR ]; then echo \"/opt/instantclient/\"; else echo $OCI_LIB_DIR; fi)",
},
"libraries": [ "-locci", "-lclntsh", "-lnnz12" ],
"link_settings": {"libraries": [ '-L<(oci_lib_dir)'] }
}],
["OS=='win'", { ["OS=='win'", {
"configurations": {
"Release": {
"msvs_settings": {
"VCCLCompilerTool": {
"RuntimeLibrary": "2"
}
},
},
"Debug": {
"msvs_settings": {
"VCCLCompilerTool": {
"RuntimeLibrary": "3"
}
},
}
},
"variables": { "variables": {
"oci_include_dir%": "<!(IF DEFINED OCI_INCLUDE_DIR (echo %OCI_INCLUDE_DIR%) ELSE (echo C:\oracle\instantclient\sdk\include))", "oci_include_dir%": "<!(IF DEFINED OCI_INCLUDE_DIR (echo %OCI_INCLUDE_DIR%) ELSE (echo C:\oracle\instantclient\sdk\include))",
"oci_lib_dir%": "<!(IF DEFINED OCI_LIB_DIR (echo %OCI_LIB_DIR%) ELSE (echo C:\oracle\instantclient\sdk\lib\msvc))", "oci_lib_dir%": "<!(IF DEFINED OCI_LIB_DIR (echo %OCI_LIB_DIR%) ELSE (echo C:\oracle\instantclient\sdk\lib\msvc))",
}, },
# "libraries": [ "-loci" ], # "libraries": [ "-loci" ],
"link_settings": {"libraries": [ '<(oci_lib_dir)\oraocci11.lib'] } "link_settings": {"libraries": [ '<(oci_lib_dir)\oraocci12.lib'] }
}] }]
], ],
"include_dirs": [ "<(oci_include_dir)" ], "include_dirs": [ "<(oci_include_dir)" ],
Expand All @@ -36,3 +58,4 @@
] ]
} }



18 changes: 17 additions & 1 deletion lib/oracle.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,10 +2,26 @@
var bindings = require("../build/Release/oracle_bindings"); var bindings = require("../build/Release/oracle_bindings");
var oracle = new bindings.OracleClient(); var oracle = new bindings.OracleClient();


function getSettings(settings) {
settings = settings || {
hostname: '127.0.0.1',
database: 'XE'
};
settings.hostname = settings.hostname || settings.host;
settings.user = settings.user || settings.username;
return settings;
}

exports.connect = function(settings, callback) { exports.connect = function(settings, callback) {
settings = getSettings(settings);
oracle.connect(settings, callback); oracle.connect(settings, callback);
} }


exports.connectSync = function(settings) {
settings = getSettings(settings);
return oracle.connectSync(settings);
}

exports.OutParam = bindings.OutParam; exports.OutParam = bindings.OutParam;


exports.OCCIINT = 0; exports.OCCIINT = 0;
Expand All @@ -17,4 +33,4 @@ exports.OCCICLOB = 5;
exports.OCCIDATE = 6; exports.OCCIDATE = 6;
exports.OCCITIMESTAMP = 7; exports.OCCITIMESTAMP = 7;
exports.OCCINUMBER = 8; exports.OCCINUMBER = 8;
exports.OCCIBLOB = 9; exports.OCCIBLOB = 9;
4 changes: 4 additions & 0 deletions package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
{ {
"name": "Joe Ferner", "name": "Joe Ferner",
"email": "joe@fernsroth.com" "email": "joe@fernsroth.com"
},
{
"name": "Raymond Feng",
"email": "raymond@strongloop.com"
} }
], ],
"bugs": { "bugs": {
Expand Down
Loading

0 comments on commit b22b009

Please sign in to comment.