node-oracledb/README.md

140 lines
6.3 KiB
Markdown
Raw Normal View History

2016-05-16 07:19:15 +08:00
# node-oracledb version 1.9
2015-01-21 00:51:22 +08:00
## <a name="about"></a> About node-oracledb
2015-01-21 00:51:22 +08:00
The node-oracledb add-on for Node.js powers high performance Oracle
Database applications.
2015-01-21 00:51:22 +08:00
2016-05-16 07:57:17 +08:00
Use node-oracledb to connect Node.js 0.10, 0.12, 4, 5 and 6 to
Oracle Database.
2015-01-21 00:51:22 +08:00
The add-on is stable, well documented, and has a comprehensive test suite.
2015-01-21 00:51:22 +08:00
The node-oracledb project is open source and maintained by Oracle Corp. The home page is on the
[Oracle Technology Network](http://www.oracle.com/technetwork/database/database-technologies/scripting-languages/node_js/).
2015-01-21 00:51:22 +08:00
2015-08-17 14:05:00 +08:00
### Node-oracledb supports:
- [Promises](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#promiseoverview), Callbacks and Streams
2015-08-17 14:05:00 +08:00
- [SQL and PL/SQL execution](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#sqlexecution)
- [REF CURSORs](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#refcursors)
- [Large Objects: CLOBs and BLOBs](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#lobhandling)
2016-07-08 14:56:23 +08:00
- Oracle Database 12.1 [JSON datatype](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#jsondatatype)
- [Query results as JavaScript objects or arrays](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#queryoutputformats)
2015-08-17 14:05:00 +08:00
- [Smart mapping between JavaScript and Oracle types with manual override available](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#typemap)
- [Data binding using JavaScript objects or arrays](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#bind)
- [Transaction Management](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#transactionmgt)
- [Inbuilt Connection Pool with Queueing](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#connpooling)
2015-08-17 14:05:00 +08:00
- [Database Resident Connection Pooling (DRCP)](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#drcp)
- [External Authentication](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#extauth)
- [Row Prefetching](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#rowprefetching)
- [Statement Caching](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#stmtcache)
- [Client Result Caching](http://docs.oracle.com/database/121/ADFNS/adfns_perf_scale.htm#ADFNS464)
2015-09-02 18:54:40 +08:00
- [End-to-end Tracing, Mid-tier Authentication, and Auditing](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#endtoend)
2016-05-16 07:21:25 +08:00
- Oracle High Availability Features
2015-08-17 14:05:00 +08:00
- [Fast Application Notification (FAN)](http://docs.oracle.com/database/121/ADFNS/adfns_avail.htm#ADFNS538)
- [Runtime Load Balancing (RLB)](http://docs.oracle.com/database/121/ADFNS/adfns_perf_scale.htm#ADFNS515)
- [Transparent Application Failover (TAF)](http://docs.oracle.com/database/121/ADFNS/adfns_avail.htm#ADFNS534)
Various Oracle Database and Oracle Client versions, can be used.
Oracle's cross-version compatibility allows one node-oracledb
installation to connect to different database versions.
2015-08-17 14:05:00 +08:00
We are actively working on supporting the best Oracle Database
features, and on functionality requests from
[users involved in the project](https://github.com/oracle/node-oracledb/issues).
## <a name="installation"></a> Installation
Prerequisites:
- [Python 2.7](https://www.python.org/downloads/)
- C Compiler with support for C++ 11 (Xcode, gcc, Visual Studio or similar)
2016-05-16 07:21:25 +08:00
- The small, free [Oracle Instant Client](http://www.oracle.com/technetwork/database/features/instant-client/index-100365.html) "basic" and "SDK" packages if your database is remote. Or use the libraries and headers from a locally installed database such as the free [Oracle XE](http://www.oracle.com/technetwork/database/database-technologies/express-edition/overview/index.html) release
2016-03-24 14:09:53 +08:00
- Set `OCI_LIB_DIR` and `OCI_INC_DIR` during installation if the Oracle libraries and headers are in a non-default location
Run `npm install oracledb` to install from the [NPM registry](https://www.npmjs.com/package/oracledb).
See [INSTALL](https://github.com/oracle/node-oracledb/tree/master/INSTALL.md) for details.
## <a name="examples"></a> Examples
There are examples in the [examples](https://github.com/oracle/node-oracledb/tree/master/examples) directory.
### A simple query example with callbacks:
2015-01-21 00:51:22 +08:00
```javascript
var oracledb = require('oracledb');
oracledb.getConnection(
{
user : "hr",
password : "welcome",
connectString : "localhost/XE"
},
function(err, connection)
{
2015-08-17 14:05:00 +08:00
if (err) { console.error(err.message); return; }
2015-01-21 00:51:22 +08:00
connection.execute(
2015-09-02 18:04:07 +08:00
"SELECT department_id, department_name " +
"FROM departments " +
"WHERE manager_id < :id",
[110], // bind value for :id
2015-01-21 00:51:22 +08:00
function(err, result)
{
2015-08-17 14:05:00 +08:00
if (err) { console.error(err.message); return; }
2015-01-21 00:51:22 +08:00
console.log(result.rows);
});
});
```
With Oracle's sample HR schema, the output is:
```
2015-09-02 18:04:07 +08:00
[ [ 60, 'IT' ], [ 90, 'Executive' ], [ 100, 'Finance' ] ]
2015-01-21 00:51:22 +08:00
```
Node Promises can also be used.
## <a name="doc"></a> Documentation
2015-01-21 00:51:22 +08:00
See [Documentation for the Oracle Database Node.js Add-on](https://github.com/oracle/node-oracledb/tree/master/doc/api.md).
2015-01-21 00:51:22 +08:00
2016-07-08 14:55:43 +08:00
## <a name="help"></a> Help
Issues and questions can be raised with the node-oracledb community on [GitHub](https://github.com/oracle/node-oracledb/issues).
## <a name="changes"></a> Changes
2015-05-05 00:53:11 +08:00
2016-07-08 14:55:43 +08:00
See [CHANGELOG](https://github.com/oracle/node-oracledb/tree/master/CHANGELOG.md).
2015-05-05 00:53:11 +08:00
2016-07-08 14:55:43 +08:00
## <a name="testing"></a> Tests
2015-08-17 14:05:00 +08:00
To run the test suite see [test/README](https://github.com/oracle/node-oracledb/tree/master/test/README.md).
2015-08-17 14:05:00 +08:00
## <a name="contrib"></a> Contributing
2015-01-21 00:51:22 +08:00
Node-oracledb is an open source project. See
2015-08-17 14:05:00 +08:00
[CONTRIBUTING](https://github.com/oracle/node-oracledb/tree/master/CONTRIBUTING.md)
2015-01-21 00:51:22 +08:00
for details.
2015-09-25 16:51:13 +08:00
Oracle gratefully acknowledges the contributions to node-oracledb that have been made by the community.
## <a name="license"></a> License
2015-01-21 00:51:22 +08:00
2016-01-30 19:32:59 +08:00
Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
2015-01-21 00:51:22 +08:00
You may not use the identified files except in compliance with the Apache
License, Version 2.0 (the "License.")
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.