Forum Stats

  • 3,872,355 Users
  • 2,266,418 Discussions
  • 7,911,162 Comments

Discussions

Node-oracledb 0.4.2 is now on NPM

Christopher Jones-Oracle
Christopher Jones-Oracle Member Posts: 1,656 Employee
edited Apr 24, 2015 6:13PM in Node.js

The 0.4.2 version of the Oracle Database driver for Node.js is now out at: https://github.com/oracle/node-oracledb


It's now officially on the NPM registry too https://www.npmjs.com/package/oracledb

The change summary is at: https://blogs.oracle.com/opal/entry/node_oracledb_0_4_2

Answers

  • Shishir
    Shishir Member Posts: 139
    edited Apr 14, 2015 11:21AM

    Hi,

    Exciting and interesting as it seems I find it difficult to understand the usability/practicality of allowing direct connections to database from client application via JS.


    I guess one of the reasons middle-tier exists is to make database transaction and connection handling modular and shield databases from any potential threats.

    Is it possible to give some use case examples where javascript connectivity would be useful for enterprise level applications having large user base?

    Thanks,

    Shishir

  • Christopher Jones-Oracle
    Christopher Jones-Oracle Member Posts: 1,656 Employee
    edited Apr 15, 2015 6:30PM

    Node.js is a mid-tier.  It extends JavaScript.  The node-oracledb driver lets you access Oracle Database from the Node.js mid-tier just like you would use JDBC from Java, OCI8 from PHP, or cx_Oracle from Python etc.  Applications can make use of the growing Node.js ecosystem and JavaScript libraries for a wide variety of purposes.

  • Shishir
    Shishir Member Posts: 139
    edited Apr 16, 2015 5:43AM

    Hi cj - Thanks for your reply.

    Looking at the example connection the db authentication parameters are being exposed in the client side script. Is that intentional or there are ways to encrypt the parameter ?

    Also is the node.js mid-tier handling the connection pooling and recycling of db connections implicitly or the developers have to manage those aspects in their code (e.g. max connections, timeout etc) ?

    Thanks,

    S

  • Christopher Jones-Oracle
    Christopher Jones-Oracle Member Posts: 1,656 Employee
    edited Apr 16, 2015 11:53AM

    The node-oracledb doc answers these questions: https://github.com/oracle/node-oracledb/blob/master/doc/api.md

    You can use external authentication.  There is both connection (i.e OCI session) pooling in node-oracledb process, and Database Resident Connection Pooling. These are configurable.

  • lake
    lake Member Posts: 1,156 Bronze Badge
    edited Apr 24, 2015 4:56PM

    This is great. I have a question though, on windows 64 bits, where should the module be installed?

    I ended up with these things generated:

    C:\node-oracledb\node_modules\oracledb\build\Release

    obj (directory)

    oracledb.exp

    oracledb.lib

    oracledb.node

    oracledb.pdb

    When I try to run a program like select1.js I get:

    Cannot find module 'oracledb'

    What has to go where in order for it to find the module? I notice that there is a module under the node directory:

    C:\Program Files\nodejs\node_modules

    which contains npm currently. Is that where oracledb.node should go? So far I'm not getting that to work. This being windows it's

    better to not keep adding things to the path as there is a limit to the size of it.

  • lake
    lake Member Posts: 1,156 Bronze Badge
    edited Apr 24, 2015 5:37PM

    BTW this is not working either:

    npm install oracledb -g

    which put this in the path:

    C:\Users\Administrator\AppData\Roaming\npm

    under which is :

    node_modules\oracledb\(etc stuff)

    And the bottom line is, it's still not finding the module:

    Error: Cannot find module 'oracledb'

  • lake
    lake Member Posts: 1,156 Bronze Badge
    edited Apr 24, 2015 5:44PM

    This doesn't work either finding oracledb.js and putting it in the path. I guess I'll be shelving this idea for a while.

  • lake
    lake Member Posts: 1,156 Bronze Badge
    edited Apr 24, 2015 6:13PM

    Ok I found out one way that you can get node to find the module based on this info:

    Where Does Node.js And Require() Look For Modules?

    Suppose you compiled your module from this directory:

    node-oracledb

    which resulted in node_modules under that directory. Then have it that your example code is in node-oracledb so that the

    node_modules are under that directory. Seems to work!