Skip to content

Commit ae97160

Browse files
committed
Update documentation for use of privileges with createPool function
1 parent 46f7ef3 commit ae97160

File tree

3 files changed

+91
-11
lines changed

3 files changed

+91
-11
lines changed

doc/src/api_manual/oracledb.rst

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,6 +2213,18 @@ Oracledb Methods
22132213
See :ref:`Connection Pool Cache <connpoolcache>` for details and examples.
22142214

22152215
.. versionadded:: 1.11
2216+
* - ``privilege``
2217+
- Number
2218+
- Thin
2219+
- .. _createpoolpoolattrsprivilege:
2220+
2221+
The privilege to use when establishing a connection to the database. This optional property should be one of the :ref:`privileged connection constants <oracledbconstantsprivilege>`. All privileges must be specified individually except for ``oracledb.SYSPRELIM``.
2222+
2223+
``oracledb.SYSPRELIM`` is specified only for startup and shutdown calls and must be used in combination with ``SYSDBA`` (``oracledb.SYSDBA | oracledb.SYSPRELIM``) or ``SYSOPER`` (``oracledb.SYOPER | oracledb.SYSPRELIM``).
2224+
2225+
See :ref:`Privileged Connections <privconn>` for more information.
2226+
2227+
.. versionadded:: 6.5.1
22162228
* - ``configDir``
22172229
- String
22182230
- Thin
@@ -3075,13 +3087,17 @@ Oracledb Methods
30753087
- Both
30763088
- .. _getconnectiondbattrsprivilege:
30773089

3078-
The privilege to use when establishing connection to the database. This optional property should be one of the :ref:`privileged connection constants <oracledbconstantsprivilege>`. Multiple privileges may be used by when required, for example ``oracledb.SYSDBA | oracledb.SYSPRELIM``.
3090+
The privilege to use when establishing connection to the database. This optional property should be one of the :ref:`privileged connection constants <oracledbconstantsprivilege>`. All privileges must be specified individually except for ``oracledb.SYSPRELIM``.
30793091

3080-
See :ref:`Privileged Connections <privconn>` for more information.
3092+
``oracledb.SYSPRELIM`` is specified only for startup and shutdown calls and must be used in combination with ``SYSDBA`` (``oracledb.SYSDBA | oracledb.SYSPRELIM``) or ``SYSOPER`` (``oracledb.SYOPER | oracledb.SYSPRELIM``).
30813093

3082-
Note only non-pooled connections can be privileged.
3094+
See :ref:`Privileged Connections <privconn>` for more information.
30833095

30843096
.. versionadded:: 2.1
3097+
3098+
.. versionchanged:: 6.5.1
3099+
3100+
The database privilege can be specified for pooled connections.
30853101
* - ``shardingKey``
30863102
- Array
30873103
- Thick

doc/src/user_guide/appendix_a.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,12 @@ differs from the node-oracledb Thick mode in the following ways:
598598
The node-oracledb Thick mode does not support all the connection mode
599599
privileges.
600600

601+
- In node-oracledb Thin mode, :ref:`privileged connections <privconn>` can be
602+
created with homogeneous pools.
603+
604+
The node-oracledb Thick mode can only create privileged connections with
605+
:ref:`heterogeneous pools <connpoolproxy>`.
606+
601607
- In node-oracledb Thick mode, the worker threads can be increased by setting
602608
the environment variable ``UV_THREADPOOL_SIZE`` before starting Node.js. This
603609
is not applicable to the Thin mode since it does not use threads.

doc/src/user_guide/connection_handling.rst

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2995,11 +2995,14 @@ at different times. Another example is when using a statement boundary of
29952995
Privileged Connections
29962996
======================
29972997
2998-
Database privileges such as ``SYSDBA`` can be obtained when using
2999-
standalone connections. Use one of the :ref:`Privileged Connection
3000-
Constants <oracledbconstantsprivilege>` with the connection
3001-
:ref:`privilege <getconnectiondbattrsprivilege>` property, for
3002-
example:
2998+
Database privileges such as ``SYSDBA`` or ``SYSOPER`` can be associated with
2999+
the user when creating standalone and pooled connections. You can use one of
3000+
the :ref:`Privileged Connection Constants <oracledbconstantsprivilege>` as the
3001+
database privilege for the user.
3002+
3003+
For :ref:`standalone connections <standaloneconnection>`, you must set the
3004+
:ref:`privilege <getconnectiondbattrsprivilege>` property in
3005+
:meth:`oracledb.getConnection()` as shown in the example below:
30033006
30043007
.. code-block:: javascript
30053008
@@ -3012,9 +3015,64 @@ example:
30123015
30133016
console.log("I have power");
30143017
3015-
Note that if node-oracledb is using the Oracle Client libraries located
3016-
in the Oracle Database installation, that is on the same machine as the
3017-
database and is not using Oracle Instant Client, then operating system
3018+
For :ref:`pooled connections <connpooling>` with node-oracledb Thin mode, you
3019+
must set the :ref:`privilege <createpoolpoolattrsprivilege>`,
3020+
:ref:`user <createpoolpoolattrsuser>`, and
3021+
:ref:`password <createpoolpoolattrspassword>` properties in
3022+
:meth:`oracledb.createPool()`. For example:
3023+
3024+
.. code-block:: javascript
3025+
3026+
const pool = await oracledb.createPool({
3027+
user : "sys",
3028+
password : "secret",
3029+
connectString : "localhost/orclpdb1",
3030+
privilege : oracledb.SYSDBA
3031+
poolMin : 2,
3032+
poolMax : 10
3033+
});
3034+
3035+
const connection = await pool.getConnection();
3036+
3037+
The ability to specify database privileges with pooled connections in Thin
3038+
mode was introduced in node-oracledb 6.5.1.
3039+
3040+
For node-oracledb Thick mode, privileged connections can only be created with
3041+
a :ref:`heterogeneous pool <connpoolproxy>`. You must set the
3042+
:ref:`homogeneous <createpoolpoolattrshomogeneous>` property to *false* in
3043+
:meth:`oracledb.createPool()` to use a heterogeneous pool. You can then
3044+
specify the :ref:`privilege <getconnectiondbattrsprivilege>`,
3045+
:ref:`user <getconnectiondbattrsuser>`, and
3046+
:ref:`password <getconnectiondbattrspassword>` properties in
3047+
:meth:`pool.getConnection()`. For example:
3048+
3049+
.. code-block:: javascript
3050+
3051+
const pool = await oracledb.createPool({
3052+
connectString : "localhost/orclpdb1",
3053+
homogeneous : false,
3054+
poolMax : 10
3055+
});
3056+
3057+
const connection = await pool.getConnection({
3058+
user : "sys",
3059+
password : "secret",
3060+
privilege : oracledb.SYSDBA
3061+
})
3062+
3063+
If you create a homogeneous pool with an invalid value specified in the
3064+
:ref:`privilege <createpoolpoolattrsprivilege>` property of
3065+
:meth:`oracledb.createPool()` in both node-oracledb Thin and Thick modes, then
3066+
the following error is raised::
3067+
3068+
NJS-007: invalid value for "privilege" in parameter 1
3069+
3070+
However, any valid ``privilege`` property value is ignored in node-oracledb
3071+
Thick mode during homogeneous pool creation.
3072+
3073+
Note that if node-oracledb Thick mode is using the Oracle Client libraries
3074+
located in the Oracle Database installation, that is on the same machine as
3075+
the database and is not using Oracle Instant Client, then operating system
30183076
privileges may be used for authentication. In this case the password
30193077
value is ignored. For example on Linux, membership of the operating
30203078
system `dba <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=

0 commit comments

Comments
 (0)