1. API: Oracledb Class
The Oracledb object is the factory class for Pool and Connection objects.
The Oracledb object is instantiated by loading node-oracledb:
const oracledb = require("oracledb"); Internally, the add-on creates the Oracledb object as a singleton. Reloading it in the same Node.js process creates a new pointer to the same object.
1.1. Oracledb Constants
These constants are defined in the oracledb module. Usage is described later in this document.
The numeric values for the constants are shown to aid debugging. They may change in future, so use the constant names in applications.
1.1.1. Query outFormat Constants
Constants for the query result outFormat option:
Constant Name | Value | Description |
|---|---|---|
| 4001 | Fetch each row as array of column values. Added in version 4.0. |
| 4002 | Fetch each row as an object. Added in version 4.0. |
The previous constants oracledb.ARRAY and oracledb.OBJECT are deprecated but still usable.
1.1.2. Oracle Database Type Objects
These database type objects indicate the Oracle Database type in metaData, DbObject types, and in the lob type property. Some database type objects can also be used for:
the execute() bindParamstype and the executeMany() bindDefs
typepropertiesthe
createLob()typeparameterfetchAsBuffer,fetchAsString, fetchInfo, andfetchTypeHandler
Note that the Oracle Database Type constants were changed to database type objects in node-oracledb 6.0. When comparing fetch types, ensure that you are using the database type object name instead of the database type number. For example, use result.metadata[0].fetchType == oracledb.DB_TYPE_VARCHAR instead of result.metadata[0].fetchType == 2001.
DbType Object | Value | Database Data Type |
|---|---|---|
| 2020 | BFILE |
| 2008 | BINARY_DOUBLE |
| 2007 | BINARY_FLOAT |
| 2009 | BINARY_INTEGER, PLS_INTEGER, SMALLINT, etc. |
| 2019 | BLOB |
| 2022 | PL/SQL BOOLEAN |
| 2003 | CHAR |
| 2017 | CLOB |
| 2021 | SYS_REFCURSOR, Nested Cursors |
| 2011 | DATE |
| 2015 | INTERVAL DAY TO SECOND Added in version 6.8. |
| 2016 | INTERVAL YEAR TO MONTH Added in version 6.8. |
| 2027 | JSON Added in version 5.1. |
| 2024 | LONG |
| 2031 | LONG |
| 2025 | LONG RAW |
| 2004 | NCHAR |
| 2018 | NCLOB |
| 2010 | NUMBER or FLOAT |
| 2002 | NVARCHAR |
| 2023 | OBJECT |
| 2006 | RAW |
| 2005 | ROWID |
| 2012 | TIMESTAMP |
| 2014 | TIMESTAMP WITH LOCAL TIME ZONE |
| 2013 | TIMESTAMP WITH TIME ZONE |
| 2001 | VARCHAR2 |
| 2032 | XMLTYPE |
| 2033 | VECTOR Added in version 6.5. |
Changed in version 4.0: The values of the constants were changed. This change is not applicable to the constants introduced after node-oracledb 4.0.
1.1.3. Node-oracledb Type Constants
From node-oracledb 4.0, these constant values changed and became aliases for common Oracle Database Type Constants.
Constant Name | Value |
| Notes |
|---|---|---|---|
| 2019 |
| |
| 2006 |
| |
| 2017 |
| |
| 2021 |
| |
| 2014 |
| |
| 0 | NA | Used with |
| 2010 |
| |
| 2018 |
| Added in version 4.2. |
| 2001 |
|
1.1.4. Execute Bind Direction Constants
Constants for the dir property of execute() bindParams, connection.queryStream() and executeMany() bindDefs.
These specify whether data values bound to SQL or PL/SQL bind parameters are passed into, or out from, the database:
Constant Name | Value | Description |
|---|---|---|
| 3001 | Direction for IN binds. |
| 3002 | Direction for IN OUT binds. |
| 3003 | Direction for OUT binds. |
1.1.5. Privileged Connection Constants
Constants for getConnection() privilege properties.
These specify what privilege should be used by the connection that is being established.
Constant Name | Value | Description |
|---|---|---|
| 32768 | SYSASM privileges |
| 131072 | SYSBACKUP privileges |
| 2 | SYSDBA privileges |
| 262144 | SYSDG privileges |
| 524288 | SYSKM privileges |
| 4 | SYSOPER privileges |
| 8 | Preliminary privilege required when starting up a database with Added in version 5.0. |
| 1048576 | SYSRAC privileges |
1.1.6. SQL Statement Type Constants
Constants for connection.getStatementInfo() properties.
Constant Name | Value | Description |
|---|---|---|
| 7 | ALTER |
| 8 | BEGIN |
| 10 | CALL |
| 21 | COMMIT |
| 5 | CREATE |
| 9 | DECLARE |
| 3 | DELETE |
| 6 | DROP |
| 15 | EXPLAIN_PLAN |
| 4 | INSERT |
| 16 | MERGE |
| 17 | ROLLBACK |
| 1 | SELECT |
| 0 | UNKNOWN |
| 2 | UPDATE |
1.1.7. Subscription Constants
Constants for the Continuous Query Notification (CQN) message.type.
Constant Name | Value | Description |
|---|---|---|
| 100 | Advanced Queuing notifications are being used. |
| 5 | A subscription has been closed or the timeout value has been reached. |
| 6 | Object-level notifications are being used (Database Change Notification). |
| 7 | Query-level notifications are being used (Continuous Query Notification). |
| 2 | The database is being shut down. |
| 3 | An instance of Oracle Real Application Clusters (RAC) is being shut down. |
| 1 | The database is being started up. |
Constant for the CQN groupingClass.
Constant Name | Value | Description |
|---|---|---|
| 1 | Group notifications by time into a single notification |
Constants for the CQN groupingType.
Constant Name | Value | Description |
|---|---|---|
| 2 | The last notification in the group is sent. |
| 1 | A summary of the grouped notifications is sent. |
Constants for the CQN qos Quality of Service.
Constant Name | Value | Description |
|---|---|---|
| 16 | When best effort filtering for query result set changes is acceptable. False positive notifications may be received. This behavior may be suitable for caching applications. |
| 2 | The subscription will be automatically unregistered as soon as the first notification is received. |
| 8 | CQN will be used instead of Database Change Notification. This means that notifications are only sent if the result set of the registered query changes. By default no false positive notifications are generated. Use |
| 1 | Notifications are not lost in the event of database failure. |
| 4 | Notifications include the ROWIDs of the rows that were affected. |
Constants for the CQN namespace.
Constant Name | Value | Description |
|---|---|---|
| 1 | For Advanced Queuing notifications. |
| 2 | For Continuous Query Notifications. |
1.1.8. Advanced Queuing Constants
Refer to Advanced Queuing documentation for more details about attributes.
Constants for AqDeqOptions Class mode.
Constant Name | Value | Description |
|---|---|---|
| 1 | Read a message without acquiring a lock. |
| 2 | Read and obtain write lock on message. |
| 3 | Read the message and delete it. |
| 4 | Delete message without returning payload. |
Constants for AqDeqOptions Class navigation.
Constant Name | Value | Description |
|---|---|---|
| 1 | Get the message at the head of queue. |
| 2 | Get the first message of next transaction group. |
| 3 | Get the next message in the queue. |
Constants for AqDeqOptions Class wait.
Constant Name | Value | Description |
|---|---|---|
| 0 | Do not wait if no message is available. |
| 4294967295 | Wait forever if no message is available. |
Constants for AqEnqOptions Class and AqDeqOptions Class deliveryMode.
Constant Name | Value | Description |
|---|---|---|
| 1 | Messages are persistent. |
| 2 | Messages are buffered. For multi-consumer queues, a subscriber with buffered delivery mode needs to be created prior to enqueuing buffered messages. |
| 3 | Messages are either persistent or buffered. |
Constants for AqMessage Class state.
Constant Name | Value | Description |
|---|---|---|
| 0 | Consumers can dequeue messages that are in the READY state. |
| 1 | Message is hidden for a given retry delay interval. |
| 2 | All intended consumers have successfully dequeued the message. |
| 3 | One or more consumers did not dequeue the message before the expiration time. |
Constants for AqEnqOptions Class and AqDeqOptions Class visibility.
Constant Name | Value | Description |
|---|---|---|
| 1 | The message is not part of the current transaction. It constitutes a transaction on its own. |
| 2 | The message is part of the current transaction. |
1.1.9. Continuous Query Notification (CQN) Constants
Constants for Continuous Query Notification (CQN) are integer mask values for the following properties of the options parameter in the connection.subscribe() method:
operations property
Constant Name | Value | Description |
|---|---|---|
| 0 | Default. Used to request notification of all operations. |
| 1 | Indicates that row information is not available. This occurs if qos quality of service flags do not specify the desire for ROWIDs, or if grouping has taken place and summary notifications are being sent. |
| 16 | Set if the table was altered in the notifying transaction. |
| 8 | Set if the notifying transaction included deletes on the table. |
| 32 | Set if the table was dropped in the notifying transaction. |
| 2 | Set if the notifying transaction included inserts on the table. |
| 4 | Set if the notifying transaction included updates on the table. |
1.1.10. Pool Status Constants
Constants for the connection pool.status read-only attribute.
Constant Name | Value | Description |
|---|---|---|
| 6002 | The connection pool has been closed. |
| 6001 | The connection pool is being drained of in-use connections and will be force closed soon. |
| 6000 | The connection pool is open. |
| 6003 | A |
1.1.11. Simple Oracle Document Access (SODA) Constants
Constant Name | Value | Description |
|---|---|---|
| 5001 | Indicate |
1.1.12. Database Shutdown Constants
Constants for shutting down the Oracle Database with oracledb.shutdown() and connection.shutdown().
Added in version 5.0.
Constant Name | Value | Description |
|---|---|---|
| 4 | All uncommitted transactions are terminated and not rolled back. This is the fastest way to shut down the database, but the next database start up may require instance recovery. |
| 0 | Further connections to the database are prohibited. Wait for users to disconnect from the database. |
| 5 | Used with a second |
| 3 | All uncommitted transactions are terminated and rolled back and all connections to the database are closed immediately. |
| 1 | Further connections to the database are prohibited and no new transactions are allowed to be started. Wait for active transactions to complete. |
| 2 | Behaves the same way as |
1.1.13. Two-Phase Commit Constants
Added in version 5.3.
Constants for two-phase commit (TPC) functions connection.tpcBegin() and connection.tpcEnd().
Constant Name | Value | Description |
|---|---|---|
| 2 | Join an existing two-phase commit (TPC) transaction. |
| 1 | Create a new TPC transaction. |
| 4 | Resume an existing TPC transaction. |
| 8 | Promote a local transaction to a TPC transaction. |
| 0 | End the TPC transaction participation normally. |
| 1048576 | Suspend the TPC transaction. |
1.1.14. Vector Type Constants
Added in version 6.5.
Constants for the vectorFormat attribute.
Constant Name | Value | Description |
|---|---|---|
| 2 | The storage format of each dimension value in the VECTOR column is a 32-bit floating-point number. |
| 3 | The storage format of each dimension value in the VECTOR column is a 64-bit floating-point number. |
| 4 | The storage format of each dimension value in the VECTOR column is an 8-bit signed integer. |
| 5 | The storage format of each dimension value in the VECTOR column is represented as a single bit. All the dimensions for the vector are stored as an array of 8-bit unsigned integers. |
Changed in version 6.6: The oracledb.VECTOR_FORMAT_BINARY constant was added.
1.2. Oracledb Properties
The properties of the Oracledb object are used for setting up configuration parameters for deployment.
If required, these properties can be overridden for the Pool or Connection objects.
These properties may be read or modified. If a property is modified, only subsequent invocations of the createPool() or getConnection() methods will be affected. Objects that exist before a property is modified are not altered.
Invalid values, or combinations of values, for pool configuration properties can result in the error ORA-24413: Invalid number of sessions specified.
Each of the configuration properties is described below.
- oracledb.autoCommit
This property is a boolean value. If this property is true, then the transaction in the current connection is automatically committed at the end of statement execution.
The default value is false.
This property may be overridden in an execute() call.
When using an external transaction manager with two-phase commits,
autoCommitshould be false.Note prior to node-oracledb 0.5 this property was called
isAutoCommit.Example
const oracledb = require('oracledb'); oracledb.autoCommit = false;
- oracledb.configProviderCacheTimeout
This property is the number of seconds that node-oracledb keeps the configuration information retrieved from a centralized configuration provider cached.
The default value is 86400 seconds.
The
config_time_to_livekey defined in a Centralized Configuration Provider overrides this property.See Caching Configuration Information.
Example
const oracledb = require('oracledb'); oracledb.configProviderCacheTimeout = 6;
- oracledb.connectionClass
The user-chosen Connection class value is a string which defines a logical name for connections. Most single purpose applications should set
connectionClasswhen using a connection pool or DRCP.When a pooled session has a connection class, the session is not shared with users with a different connection class.
The connection class value is similarly used by Database Resident Connection Pooling (DRCP) to allow or disallow sharing of sessions.
For example, where two different kinds of users share one pool, you might set
connectionClassto ‘HRPOOL’ for connections that access a Human Resources system, and it might be set to ‘OEPOOL’ for users of an Order Entry system. Users will only be given sessions of the appropriate class, allowing maximal reuse of resources in each case, and preventing any session information leaking between the two systems.If
connectionClassis set for a non-pooled connection, the driver name is not recorded inV$views. See End-to-end Tracing, Mid-tier Authentication, and Auditing.Example
const oracledb = require('oracledb'); oracledb.connectionClass = 'HRPOOL';
- oracledb.dbObjectAsPojo
This property is a boolean which specifies whether Oracle Database named objects or collections that are queried should be returned to the application as “plain old JavaScript objects” or kept as database-backed objects. This option also applies to output
BIND_OUTbind variables.Note that LOBs in objects will be represented as Lob instances and will not be String or Buffer, regardless of any
fetchAsString,fetchAsBuffer, orfetchInfosetting.The default value for
dbObjectAsPojois false.Setting
dbObjectAsPojoto true can avoid overhead if object attributes are repeatedly accessed. It also allows applications to close connections before any attributes are accessed unless LOBs are involved. Regardless of the value, the interface to access objects is the same.Example
const oracledb = require('oracledb'); oracledb.dbObjectAsPojo = false;
- oracledb.dbObjectTypeHandler
Added in version 6.8.
This property is a function which converts the data type of the DbObject property to the desired data type. This function is called once for each property inside a DbObject with a single object argument containing the following attributes:
type: The value of one of the Oracle Database Type Objects.maxSize: The maximum number of bytes allocated.typeName: The name of the object.precision: Set only fororacledb.DB_TYPE_NUMBERtype.scale: Set only fororacledb.DB_TYPE_NUMBERtype.
The function is expected to return an object containing a
converterattribute which works similar to the existing fetch type handler’s converters. The DbObject type handler’sconverterattribute is a function which accepts the incoming read value of the DbObject property and returns a transformed value (based on the required data type) for the same DbObject property.This property is not applicable for LOB data type attributes of a DbObject type.
See Using DbObject Type Handlers.
Example
const oracledb = require('oracledb'); const myDbObjectFetchTypeHandler = function(metadata) { if(metadata.type == oracledb.DB_TYPE_NUMBER) { return { converter: (val) => { // The default string value received is converted to new types // like BigInt return BigInt(val); } }; } } oracledb.dbObjectTypeHandler = myDbObjectFetchTypeHandler;
- oracledb.driverName
Added in version 6.7.
This property is a string that specifies the name of the driver used by the client to connect to Oracle Database. This is equivalent to the value in the
CLIENT_DRIVERcolumn of theV$SESSION_CONNECT_INFOview.This property may be overridden when creating a
standalone connectionor aconnection pool.Note
This property can only be used in node-oracledb Thin mode.
Example
const oracledb = require('oracledb'); oracledb.driverName = 'mydriver';
- oracledb.edition
Added in version 2.2.
This property is a string that sets the name used for Edition-Based Redefinition by connections.
See Edition-Based Redefinition for more information.
Example
const oracledb = require('oracledb'); oracledb.edition = 'ed_2';
Changed in version 6.8: Support for this property was added in node-oracledb Thin mode.
- oracledb.errorOnConcurrentExecute
Added in version 5.2.
This property is a boolean that can be set to throw an error if concurrent operations are attempted on a single connection.
The default value for
errorOnConcurrentExecuteis false.Each Oracle connection can only interact with the database for one operation at a time. Attempting to do more than one operation concurrently may be a sign of an incorrectly coded application, for example an
awaitmay be missing. Examples of operations that cannot be executed in parallel on a single connection includeconnection.execute(),connection.executeMany(),connection.queryStream(),connection.getDbObjectClass(),connection.commit(),connection.close(), SODA calls, and streaming from Lobs.The value of this property does not affect using multiple connections. These may all be in use concurrently, and each can be doing one operation.
Leaving
errorOnConcurrentExecuteset to false is recommended for production applications. This will avoid unexpected errors. Some frameworks may execute concurrent statements on a connection by design. Also some application modules may have the expectation that node-oracledb will handle any necessary connection usage serialization.For more discussion, see Parallelism on Each Connection.
Example
const oracledb = require('oracledb'); oracledb.errorOnConcurrentExecute = false;
- oracledb.events
Added in version 2.2.
This property is a boolean that determines whether Oracle Client events mode should be enabled.
The default value for
eventsis false.This property can be overridden in the oracledb.createPool() call and when getting a standalone connection from oracledb.getConnection().
Events mode is required for
Continuous Query Notification, Fast Application Notification (FAN) and Runtime Load Balancing (RLB).In node-oracledb 4.0.0 and 4.0.1, the default value for
eventswas true.Note
This property can only be used in node-oracledb Thick mode. See Enabling node-oracledb Thick Mode.
Example
const oracledb = require('oracledb'); oracledb.events = false;
- oracledb.extendedMetaData
Desupported in version 6.0.
Extended metadata is now always returned
Added in version 1.10.
This property is a boolean that determines whether additional metadata is available for queries and for REF CURSORs returned from PL/SQL blocks.
The default value for
extendedMetaDatais false. With this value, the result.metaData andresultSet.metaDataobjects only include column names.If
extendedMetaDatais true thenmetaDatawill contain additional attributes. These are listed in Result Object Properties.This property may be overridden in an execute() call.
- oracledb.externalAuth
This property is a boolean value. If this property is true in node-oracledb Thick mode, then connections are established using external authentication. See External Authentication for more information.
In node-oracledb Thin mode, when token-based authentication or external authentication using TLS is required, this property must be set to true. In all the other cases where this property is set to true, an error is thrown.
The default value is false.
The
user(orusername) andpasswordproperties should not be set whenexternalAuthis true.This property can be overridden in the
oracledb.createPool()call and when getting a standalone connection fromoracledb.getConnection().Note prior to node-oracledb 0.5 this property was called
isExternalAuth.Example
const oracledb = require('oracledb'); oracledb.externalAuth = false;
- oracledb.fetchArraySize
Added in version 2.0.
This property is a number that sets the size of an internal buffer used for fetching query rows from Oracle Database. Changing it may affect query performance but does not affect how many rows are returned to the application.
The default value is 100.
The property is used during the default direct fetches, during ResultSet
resultset.getRow()calls, and forconnection.queryStream(). It is used forresultset.getRows()when no argument (or the value 0) is passed togetRows().Increasing this value reduces the number of round-trips to the database but increases memory usage for each data fetch. For queries that return a large number of rows, higher values of
fetchArraySizemay give better performance. For queries that only return a few rows, reduce the value offetchArraySizeto minimize the amount of memory management during data fetches. JavaScript memory fragmentation may occur in some cases, see Fetching Rows with Direct Fetches.For direct fetches (those using
execute()option resultSet: false), the internal buffer size will be based on the lesser oforacledb.maxRowsandfetchArraySize.This property can be overridden by the
execute()option fetchArraySize.See Tuning Fetch Performance for more information.
Example
const oracledb = require('oracledb'); oracledb.fetchArraySize = 100;
- oracledb.fetchAsBuffer
Added in version 1.13.
This property is an array of type constants that allows query columns to be returned as Buffers.
Currently the only valid constant is oracledb.BLOB or its equivalent oracledb.DB_TYPE_BLOB.
When set, and a BLOB column is queried with
execute()orqueryStream(), then the column data is returned as a Buffer instead of the default Lob instance. Individual query columns inexecute()orqueryStream()calls can override thefetchAsBufferglobal setting by using fetchInfo.Example
const oracledb = require('oracledb'); oracledb.fetchAsBuffer = [ oracledb.BLOB ];
- oracledb.fetchAsString
This property is an array that allows query columns to be returned as Strings instead of the default type.
In node-oracledb, all columns are returned as the closest JavaScript type, or as Lob instances in the case of CLOB and NCLOB types. (See Query Result Type Mapping). The
fetchAsStringproperty can override this default type mapping.The
fetchAsStringproperty should be an array of type constants. The valid constants are oracledb.DATE, oracledb.NUMBER, oracledb.BUFFER, oracledb.CLOB, and oracledb.NCLOB. The equivalent DB_TYPE_* constants can also be used.When any column having one of the types is queried with
execute()orqueryStream(), the column data is returned as a string instead of the default representation. Individual query columns inexecute()orqueryStream()calls can override thefetchAsStringglobal setting by using fetchInfo.Note:
Specifying oracledb.NUMBER will affect numeric columns. The
fetchAsStringproperty helps avoid situations where using JavaScript types can lead to numeric precision loss.Specifying oracledb.CLOB will affect both CLOB and NCLOB columns. Similarly, specifying oracledb.NCLOB will also affect both CLOB and NCLOB columns. Using
fetchAsStringautomatically fetches LOB data directly in query output without requiring streaming.Specifying oracledb.DATE will affect date and timestamp columns. Using
fetchAsStringcan be helpful to avoid date conversions.
When oracledb.BUFFER is used for RAW data, Oracle returns the data as a hex-encoded string. For dates and numbers returned as a string, the maximum length of a string created by this mapping is 200 bytes. Strings created for CLOB and NCLOB columns will generally be limited by Node.js and V8 memory restrictions.
Example
const oracledb = require('oracledb'); oracledb.fetchAsString = [ oracledb.DATE, oracledb.NUMBER ];
- oracledb.fetchTypeHandler
Added in version 6.0.
This property is a function that allows applications to examine and modify queried column data before it is returned to the user. This function is called once for each column that is being fetched with two object arguments.
The first object argument contains the following attributes:
annotations: The object representing the annotations.byteSize: The maximum size in bytes. This is only set ifdbTypeisoracledb.DB_TYPE_VARCHAR,oracledb.DB_TYPE_CHAR, ororacledb.DB_TYPE_RAW.dbType: The database type, that is, one of the Oracle Database Type Objects.dbTypeName: The name of the database type, such as “NUMBER” or “VARCHAR2”.dbTypeClass: The class associated with the database type. This is only set ifdbTypeisoracledb.DB_TYPE_OBJECT.domainName: The name of the data use case domain.domainSchema: The schema name of the data use case domain.isJson: Indicates if the column is known to contain JSON data.name: The name of the column.nullable: Indicates whetherNULLvalues are permitted for this column.precision: Set only when thedbTypeisoracledb.DB_TYPE_NUMBER.scale: Set only when thedbTypeisoracledb.DB_TYPE_NUMBER.
By default, this property is “undefined”, that is, it is not set.
The second object argument contains the metadata list of all the result columns fetched using the SELECT statement.
The function is expected to return either nothing or an object containing:
the
typeattributeor the converter attribute
or both the
typeandconverterattributes
The
converterfunction is a function which can be used with fetch type handlers to change the returned data. This function accepts the value that will be returned byconnection.execute()for a particular row and column and returns the value that will actually be returned byconnection.execute().This property can be overridden by the fetchTypeHandler option in
execute().See Using Fetch Type Handlers.
Changed in version 6.3: The
annotations,domainName,domainSchema, andisJsoninformation attributes were added.Example
const oracledb = require('oracledb'); oracledb.fetchTypeHandler = function(metaData, rowsetMetaData) { // Return number column data as strings if (metaData.dbType == oracledb.DB_TYPE_NUMBER) { const nameColumn = rowsetMetaData.find(col => col.name === 'NAME'); console.log(nameColumn); return {type: oracledb.STRING}; } }
- oracledb.lobPrefetchSize
This property is a number and is temporarily disabled. Setting it has no effect. For best performance, fetch Lobs as Strings or Buffers.
Node-oracledb internally uses Oracle LOB Locators to manipulate long object (LOB) data. LOB Prefetching allows LOB data to be returned early to node-oracledb when these locators are first returned. This allows for efficient use of resources and round-trips between node-oracledb and the database.
Prefetching of LOBs is mostly useful for small LOBs.
The default size is 16384.
Example
const oracledb = require('oracledb'); oracledb.lobPrefetchSize = 16384;
- oracledb.machine
Added in version 6.7.
This property is a string that specifies the name of the host machine where the connection originates. This is equivalent to the value in the
MACHINEcolumn of theV$SESSIONview.This property may be overridden when creating a
standalone connectionor aconnection pool.Note
This property can only be used in node-oracledb Thin mode.
Example
const oracledb = require('oracledb'); oracledb.machine = 'mymachine';
- oracledb.maxRows
This property is the maximum number of rows that are fetched by a query with
connection.execute()when not using a ResultSet. Rows beyond this limit are not fetched from the database. A value of 0 means there is no limit.For nested cursors, the limit is also applied to each cursor.
The default value is 0, meaning unlimited.
This property may be overridden in an execute() call.
To improve database efficiency, SQL queries should use a row limiting clause like OFFSET / FETCH or equivalent. The
maxRowsproperty can be used to stop badly coded queries from returning unexpectedly large numbers of rows.For queries that return a fixed, small number of rows, then set
maxRowsto that value. For example, for queries that return one row, setmaxRowsto 1.When the number of query rows is relatively big, or can not be predicted, it is recommended to use a ResultSet or
queryStream(). This allows applications to process rows in smaller chunks or individually, preventing the Node.js memory limit being exceeded or query results being unexpectedly truncated by amaxRowslimit.In version 1, the default value was 100.
Example
const oracledb = require('oracledb'); oracledb.maxRows = 0;
- oracledb.oracleClientVersion
Added in version 1.3.
This read-only property gives a numeric representation of the Oracle Client library version which is useful in comparisons. For version a.b.c.d.e, this property gives the number:
(100000000 * a) + (1000000 * b) + (10000 * c) + (100 * d) + eFrom node-oracledb 3.1.0, using
oracledb.oracleClientVersionwill throw a DPI-1047 error if node-oracledb cannot load Oracle Client libraries. Previous versions threw this error fromrequire('oracledb').Note
This property can only be used in node-oracledb Thick mode. See Enabling node-oracledb Thick Mode.
Example
const oracledb = require('oracledb'); console.log("Oracle client library version number is " + oracledb.oracleClientVersion);
- oracledb.oracleClientVersionString
Added in version 2.2.
This read-only property gives a string representation of the Oracle Client library version which is useful for display.
From node-oracledb 3.1.0, using
oracledb.oracleClientVersionStringwill throw aDPI-1047error if node-oracledb cannot load Oracle Client libraries. Previous versions threw this error fromrequire('oracledb').Note
This property can only be used in node-oracledb Thick mode. See Enabling node-oracledb Thick Mode.
Example
const oracledb = require('oracledb'); console.log("Oracle client library version is " + oracledb.oracleClientVersionString);
- oracledb.osUser
Added in version 6.7.
This property is a string that specifies the name of the operating system user that initiates the database connection. This is equivalent to the value in the
OSUSERcolumn of theV$SESSIONview.This property may be overridden when creating a
standalone connectionor aconnection pool.Note
This method is only supported in node-oracledb Thin mode.
Example
const oracledb = require('oracledb'); oracledb.osUser = 'myuser';
- oracledb.outFormat
This property is a number that identifies the format of query rows fetched when using
connection.execute()orconnection.queryStream(). It affects both ResultSet and non-ResultSet queries. It can be used for top level queries and REF CURSOR output.This can be either of the Oracledb constants
oracledb.OUT_FORMAT_ARRAYororacledb.OUT_FORMAT_OBJECT. The default value isoracledb.OUT_FORMAT_ARRAYwhich is more efficient. The older, equivalent constantsoracledb.ARRAYandoracledb.OBJECTare deprecated.If specified as
oracledb.OUT_FORMAT_ARRAY, each row is fetched as an array of column values.If specified as
oracledb.OUT_FORMAT_OBJECT, each row is fetched as a JavaScript object. The object has a property for each column name, with the property value set to the respective column value. The property name follows Oracle’s standard name-casing rules. It will commonly be uppercase, since most applications create tables using unquoted, case-insensitive names.From node-oracledb 5.1, when duplicate column names are used in queries, then node-oracledb will append numeric suffixes in
oracledb.OUT_FORMAT_OBJECTmode as necessary, so that all columns are represented in the JavaScript object. This was extended in node-oracledb 5.2 to also cover duplicate columns in nested cursors and REF CURSORS.This property may be overridden in an execute() or
queryStream()call.See Query Output Formats for more information.
Example
const oracledb = require('oracledb'); oracledb.outFormat = oracledb.OUT_FORMAT_ARRAY;
- oracledb.poolIncrement
This property is the number of connections that are opened whenever a connection request exceeds the number of currently open connections.
The default value is 1.
With fixed-size homogeneous pools (where
poolMinequalspoolMax), and when using Oracle Client 18c (or later) for node-oracledb Thick mode, you may wish to evaluate settingpoolIncrementgreater than 1. This can expedite regrowth when the number ofconnections establishedhas become lower thanpoolMin, for example, when network issues cause connections to become unusable and get them dropped from the pool.This property may be overridden when
creating a connection pool.Example
const oracledb = require('oracledb'); oracledb.poolIncrement = 1;
- oracledb.poolMax
This property is the maximum number of connections to which a connection pool can grow.
The default value is 4.
This property may be overridden when
creating a connection pool.Importantly, if you increase
poolMaxyou should also increase the number of threads available to node-oracledb. See Connections and Number of Threads.A fixed pool size where
poolMinequalspoolMaxis strongly recommended. This helps prevent connection storms and helps overall system stability.See Connection Pooling for pool sizing guidelines.
Example
const oracledb = require('oracledb'); oracledb.poolMax = 4;
- oracledb.poolMaxPerShard
Added in version 4.1.
This property sets the maximum number of connection in the pool that can be used for any given shard in a sharded database. This lets connections in the pool be balanced across the shards. A value of zero will not set any maximum number of sessions for each shard.
This property may be overridden when
creating a connection pool.When this property is greater than zero, and a new connection request would cause the number of connections to the target shard to exceed the limit, then that new connection request will block until a suitable connection has been released back to the pool. The pending connection request will consume one worker thread.
See Connecting to Oracle Globally Distributed Database for more information.
Note
This property can only be used in node-oracledb Thick mode. See Enabling node-oracledb Thick Mode.
It is available when node-oracledb uses Oracle client libraries 18.3, or later.
Example
const oracledb = require('oracledb'); oracledb.poolMaxPerShard = 0;
- oracledb.poolMin
This property is a number that identifies the number of connections established to the database when a pool is created. Also, this is the minimum number of connections that a pool maintains when it shrinks, see
oracledb.poolTimeout.The default value is 0.
This property may be overridden when
creating a connection pool.A fixed pool size where
poolMinequalspoolMaxis strongly recommended. This helps prevent connection storms and helps overall system stability.For pools created with External Authentication, with homogeneous set to false, or when using Database Resident Connection Pooling (DRCP), then the number of connections initially created is zero even if a larger value is specified for
poolMin. Also in these cases the pool increment is always 1, regardless of the value of poolIncrement. Once the number of open connections exceedspoolMinthen the number of open connections does not fall belowpoolMin.Example
const oracledb = require('oracledb'); oracledb.poolMin = 0;
- oracledb.poolPingInterval
Added in version 1.12.
This property is a number value. When a pool
pool.getConnection()is called and the connection has been idle in the pool for at leastpoolPingIntervalseconds, node-oracledb internally “pings” the database to check the connection is alive. After a ping, an unusable connection is destroyed and a usable one is returned bygetConnection(). Connection pinging improves the chance a pooled connection is usable by the application because unusable connections are less likely to be returned byoracledb.getConnection().The default
poolPingIntervalvalue is 60 seconds. Possible values are:Table 1.24 poolPingIntervalValuespoolPingIntervalValueBehavior of a Pool
getConnection()Calln<0Never checks for connection validity.
n=0Always checks for connection validity. This value is not recommended for most applications because of the overhead in performing each ping.
n>0Checks validity if the connection has been idle in the pool (not “checked out” to the application by
getConnection()) for at leastnseconds.This property may be overridden when creating a connection pool using
oracledb.createPool().See Connection Pool Pinging for more discussion.
It was disabled when using Oracle Client 12.2 (and later) until node-oracledb 3.0.
Example
const oracledb = require('oracledb'); oracledb.poolPingInterval = 60; // seconds
- oracledb.poolPingTimeout
Added in version 6.4.
This property is the number of milliseconds that a connection should wait for a response from
connection.ping(). Ifping()does not respond by the time specified in this property, then the connection is forcefully closed.The default value is 5000 milliseconds. The behavior of a pool
getConnection()call differs based on the value specified in thepoolPingTimeoutproperty as detailed below.Table 1.25 poolPingTimeoutValuespoolPingTimeoutValueBehavior of a Pool
getConnection()Calln<0Returns the error
NJS-007: invalid value for "poolPingTimeout" in parameter 1if the poolPingTimeout property inoracledb.createPool()is set to a negative value.Returns the error
NJS-004: invalid value for property "poolPingTimeout"iforacledb.poolPingTimeoutis set to a negative value.n=0Waits until
connection.ping()succeeds with a response or fails with an error.n>0Waits for
connection.ping()to respond bynmilliseconds.If
ping()does not respond bynmilliseconds, then the connection is forcefully closed.This property may be overridden when
creating a connection pool.Example
const oracledb = require('oracledb'); oracledb.poolPingTimeout = 5000; // milliseconds
- oracledb.poolTimeout
This property is a number that allows the number of open connections in a pool to shrink to
oracledb.poolMin.If the application returns connections to the pool with
connection.close(), and the connections are then unused for more thanpoolTimeoutseconds, then any excess connections abovepoolMinwill be closed. When using Oracle Client prior to version 21, this pool shrinkage is only initiated when the pool is accessed.If
poolTimeoutis set to 0, then idle connections are never terminated.If you wish to change
poolTimeoutwithpool.reconfigure(), then the initialpoolTimeoutused byoracledb.createPool()must be non-zero.The default value is 60.
This property may be overridden when
creating a connection pool.Example
const oracledb = require('oracledb'); oracledb.poolTimeout = 60;
- oracledb.prefetchRows
This property is a query tuning option to set the number of additional rows the underlying Oracle Client library fetches during the internal initial statement execution phase of a query. The prefetch size does not affect when, or how many, rows are returned by node-oracledb to the application.
The
prefetchRowsattribute can be used in conjunction withoracledb.fetchArraySizeto tune query performance, memory use, and to reduce the number of round-trip calls needed to return query results, see Tuning Fetch Performance.The
prefetchRowsvalue is ignored in some cases, such as when the query involves a LOB.If you fetch a REF CURSOR, retrieve rows from that cursor, and then pass it back to a PL/SQL block, you should set
prefetchRowsto 0 during the initial statement that gets the REF CURSOR. This ensures that rows are not internally fetched from the REF CURSOR by node-oracledb thus making them unavailable in the final PL/SQL code.The default value is 2.
This property may be overridden in an
connection.execute()call, which is preferred usage if you need to change the value.This attribute is not used in node-oracledb version 2, 3 or 4. In those versions use only
oracledb.fetchArraySizeinstead.Example
const oracledb = require('oracledb'); oracledb.prefetchRows = 2;
- oracledb.program
Added in version 6.7.
This property is a string that specifies the name of the program connecting to the database. This is equivalent to the value in the
PROGRAMcolumn of theV$SESSIONview.This property may be overridden when creating a
standalone connectionor aconnection pool.Note
This method is only supported in node-oracledb Thin mode.
Example
const oracledb = require('oracledb'); oracledb.program = 'myprogram';
- oracledb.Promise
The ``oracledb.Promise`` property is no longer used in node-oracledb 5 and has no effect.
Node-oracledb supports Promises on all methods. The native Promise library is used. See Promises and node-oracledb for a discussion of using Promises.
Example
Prior to node-oracledb 5, this property could be set to override or disable the Promise implementation.
const mylib = require('myfavpromiseimplementation'); oracledb.Promise = mylib;
Prior to node-oracledb 5, Promises could be completely disabled by setting:
oracledb.Promise = null;
- oracledb.queueMax
Added in version 5.0.
This property is the maximum number of pending
pool.getConnection()calls that can be queued.When the number of
pool.getConnection()calls that have been queued waiting for an available connection reachesqueueMax, then any futurepool.getConnection()calls will immediately return an error and will not be queued.If
queueMaxis -1, then the queue length is not limited.The default value is 500.
This property may be overridden when
creating a connection pool.Example
const oracledb = require('oracledb'); oracledb.queueMax = 500;
- oracledb.queueRequests
This property was removed in node-oracledb 3.0 and queuing was always enabled. From node-oracledb 5.0, set
queueMaxto 0 to disable queuing. See Connection Pool Queue for more information.
- oracledb.queueTimeout
Added in version 1.7.
This property is the number of milliseconds after which connection requests waiting in the connection request queue are terminated. If
queueTimeoutis 0, then queued connection requests are never terminated.If immediate timeout is desired, set related property
oracledb.queueMaxto 0.The default value is 60000.
This property may be overridden when
creating a connection pool.See Connection Pool Queue for more information.
Example
const oracledb = require('oracledb'); oracledb.queueTimeout = 3000; // 3 seconds
- oracledb.stmtCacheSize
This property is the number of statements that are cached in the statementcache of each connection.
The default value is 30.
This property may be overridden for specific Pool or Connection objects.
In general, set the statement cache to the size of the working set of statements being executed by the application. Statement caching can be disabled by setting the size to 0.
See Statement Caching for examples.
Example
const oracledb = require('oracledb'); oracledb.stmtCacheSize = 30;
- oracledb.terminal
Added in version 6.7.
This property is a string that specifies the name of the terminal from where the connection originates. This is equivalent to the value in the
TERMINALcolumn of theV$SESSIONview.This property may be overridden when creating a
standalone connectionor aconnection pool.Note
This method is only supported in node-oracledb Thin mode.
Example
const oracledb = require('oracledb'); oracledb.terminal = 'myterminal';
- oracledb.thin
Added in version 6.0.
This property is a boolean that determines the node-oracledb driver mode which is in use. If the value is true, it indicates that node-oracledb Thin mode is in use. If the value is false, it indicates that node-oracledb Thick mode is in use.
The default value is true.
Immediately after node-oracledb is imported, this property is set to true indicating that node-oracledb defaults to Thin mode. If
oracledb.initOracleClient()is called, then the value of this property is set to False indicating that Thick mode is enabled. Once the first standalone connection or connection pool is created, or a call tooracledb.initOracleClient()is made, then node-oracledb’s mode is fixed and the value set inoracledb.thinwill never change for the lifetime of the process.The property
connection.thincan be used to check a connection’s mode and the attributepool.thincan be used to check a pool’s mode. The value that is displayed for theconnection.thin,pool.thin, andoracledb.thinattributes will be the same.
- oracledb.version
This read-only property gives a numeric representation of the node-oracledb version. For version x.y.z, this property gives the number:
(10000 * x) + (100 * y) + zExample
const oracledb = require('oracledb'); console.log("Driver version number is " + oracledb.version);
- oracledb.versionString
Added in version 2.1.
This read-only property gives a string representation of the node-oracledb version, including the version suffix if one is present.
Example
const oracledb = require('oracledb'); console.log("Driver version is " + oracledb.versionString);
- oracledb.versionSuffix
Added in version 2.1.
This read-only property gives a string representing the version suffix (for example, “-dev” or “-beta”) or an empty string if no version suffix is present.
Example
const oracledb = require('oracledb'); console.log("Driver version suffix is " + oracledb.versionSuffix);
1.3. Oracledb Methods
- oracledb.createPool()
Promise:
promise = createPool(Object poolAttrs);
Creates a pool of connections with the specified user name, password and connection string. A pool is typically created once during application initialization.
In node-oracledb Thick mode,
createPool()internally creates an Oracle Call Interface Session Pool for each Pool object.The default properties may be overridden by specifying new properties in the
poolAttrsparameter.It is possible to add pools to the pool cache when calling
createPool(). This allows pools to later be accessed by name, removing the need to pass the pool object through code. See Connection Pool Cache for more details.A pool should be terminated with the
pool.close()call.From node-oracledb 3.1.0, the
createPool()error callback will return a DPI-1047 error if node-oracledb cannot load Oracle Client libraries. Previous versions threw this error fromrequire('oracledb').See Connection Pooling for more information about pooling.
The parameters of the
oracledb.createPool()method are:Table 1.26 oracledb.createPool() Parameters Parameter
Data Type
Description
poolAttrsObject
The
poolAttrsparameter object provides connection credentials and pool-specific configuration properties, such as the maximum or minimum number of connections for the pool, or the statement cache size for the connections.The properties provided in the
poolAttrsparameter override the default pooling properties of the Oracledb object. If an attribute is not set, or is null, the value of the related Oracledb property will be used.Note that the
poolAttrsparameter may have configuration properties that are not used by thecreatePool()method. These are ignored.See createPool(): poolAttrs Parameter Properties for information on the properties of
poolAttrs.The properties of
poolAttrsare:Table 1.27 createPool(): poolAttrsParameter PropertiesProperty
Data Type
node-oracledb Mode
Description
accessTokenFunction, String, Object
Both
For Microsoft Azure Active Directory OAuth 2.0 token-based authentication,
accessTokencan be:a callback function returning the token as a string
an object with a
tokenattribute containing the token as a stringor the token as a string
Tokens can be obtained using various approaches. For example, using the Azure Active Directory API.
For Oracle Cloud Infrastructure Identity and Access Management (IAM) token-based authentication,
accessTokencan be:a callback function returning an object containing
tokenandprivateKeyattributesor an object containing
tokenandprivateKeyattributes
The properties of the
accessTokenobject are described in createPool(): accessToken Object Attributes.If
accessTokenis a callback function:function accessToken(boolean refresh, object accessTokenConfig)
When
accessTokenis a callback function, it will be invoked at the time the pool is created (even ifpoolMinis 0). It is also called when the pool needs to expand (causing new connections to be created) and the current token has expired. The returned token is used by node-oracledb for authentication. Therefreshparameter is described in createPool(): refresh Parameter Values. TheaccessTokenConfigparameter is described in accessTokenConfig.When the callback is first invoked, the
refreshparameter will be set to false. This indicates that the application can provide a token from its own application managed cache, or it can generate a new token if there is no cached value. Node-oracledb checks whether the returned token has expired. If it has expired, then the callback function will be invoked a second time withrefreshset to true. In this case the function must externally acquire a token, optionally add it to the application’s cache, and return the token.For token-based authentication, the
externalAuthandhomogeneouspool attributes must be set to true. Theuser(orusername) andpasswordattributes should not be set.See Token-Based Authentication for more information.
Added in version 5.4: The
accessTokenproperty was added to support IAM token-based authentication. For IAM token-based authentiation, this property must be an Object. For node-oracledb Thick mode, Oracle Client libraries 19.14 (or later), or 21.5 (or later) must be used for IAM token-based authentication.Changed in version 5.5: The
accessTokenproperty was extended to allow OAuth 2.0 token-based authentication in node-oracledb 5.5. For OAuth 2.0, the property should be a string, or a callback. For node-oracledb Thick mode, Oracle Client libraries 19.15 (or later), or 21.7 (or later) must be used. The callback usage supports both OAuth 2.0 and IAM token-based authentication.accessTokenCallbackObject
NA
This optional attribute is a Node.js callback function. It gets called by the connection pool if the pool needs to grow and create new connections but the current token has expired.
The callback function must return a JavaScript object with attributes
tokenandprivateKeyfor IAM. See Connection Pool Creation with Access Tokens for IAM.Added in version 5.4.
It should be used with Oracle Client libraries 19.14 (or later), or 21.5 (or later).
Deprecated since version 5.5.
Desupported in version 6.0.
Use accessToken with a callback instead.
accessTokenConfigObject
Both
An object containing the Azure-specific or OCI-specific parameters that need to be set when using the Azure Software Development Kit (SDK) or Oracle Cloud Infrastructure (OCI) SDK for token generation. This property should only be specified when the accessToken property is a callback function. For more information on the Azure-specific parameters, see sampleazuretokenauth.js and for the OCI-specific parameters, see sampleocitokenauth.js.
For OAuth2.0 token-based authentication and when using node-oracledb Thick mode, Oracle Client libraries 19.15 (or later), or 21.7 (or later) must be used. For IAM token-based authentication and when using node-oracledb Thick mode, Oracle Client libraries 19.14 (or later), or 21.5 (or later) are required.
Added in version 6.3.
appContextArray
Thin
An array of array values that identifies the application context used by the connection. The elements of the array should contain three string values - namespace, name, and value. See Application Contexts.
Added in version 6.9.
configDirString
Thin
The directory in which the Optional Oracle Net Configuration Files are found.
For node-oracledb Thick mode, use the
oracledb.initOracleClient()option configDir instead.Added in version 6.0.
connectionIdPrefixString
Thin
The application specific prefix parameter that is added to the connection identifier.
Added in version 6.0.
connectString,connectionStringString
Both
The Oracle database instance used by connections in the pool. The string can be an Easy Connect string, or a Net Service Name from a
tnsnames.orafile, or the name of a local Oracle Database instance. See Oracle Net Services Connection String for examples.Added in version 2.1: The alias
connectionStringwas added.connectTimeoutNumber
Thin
The timeout duration in seconds for an application to establish an Oracle Net connection.
There is no timeout by default.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
driverNameString
Thin
The name of the driver that is used by the client to connect to Oracle Database. This is equivalent to the value in the
CLIENT_DRIVERcolumn of theV$SESSION_CONNECT_INFOview.This optional property overrides the
oracledb.driverNameproperty.Added in version 6.7.
editionString
Both
Sets the name used for Edition-Based Redefinition by connections in the pool.
This optional property overrides the
oracledb.editionproperty.Changed in version 6.8: Support for this property was added in node-oracledb Thin mode.
Added in version 2.2.
enableStatisticsBoolean
Both
Recording of pool statistics can be enabled by setting
enableStatisticsto true. Statistics can be retrieved withpool.getStatistics(), orpool.logStatistics(). See Connection Pool Monitoring.The default value is false.
Added in version 5.2.
The obsolete property
_enableStatscan still be used, but it will be removed in a future version of node-oracledb.eventsBoolean
Thick
Indicates whether Oracle Call Interface events mode should be enabled for this pool.
This optional property overrides the
oracledb.eventsproperty.Added in version 2.2.
expireTimeNumber
Thin
The number of minutes between the sending of keepalive probes. If this property is set to a value greater than zero, it enables the keepalive probes.
The default value is 0.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
externalAuthBoolean
Both
Indicates whether pooled connections should be established using External Authentication.
The default is false.
In Thin mode, when token-based authentication or external authentication using TLS is required, this property must be set to true. In all the other cases where this property is set to true, an error is thrown.
This optional property overrides the
oracledb.externalAuthproperty.The
user(orusername) andpasswordproperties should not be set whenexternalAuthis true.Note prior to node-oracledb 0.5 this property was called
isExternalAuth.homogeneousBoolean
Both
Indicates whether connections in the pool all have the same credentials (a ‘homogeneous’ pool), or whether different credentials can be used (a ‘heterogeneous’ pool).
The default is true.
For the Thin mode, only homogeneous pools can be created. If this property is set to false in Thin mode, an error will be thrown.
When set to false in Thick mode, the user name and password can be omitted from the
connection.createPool()call, but will need to be given for subsequentpool.getConnection()calls. Differentpool.getConnection()calls can provide different user credentials. Alternatively, whenhomogeneousis false, the user name (the ‘proxy’ user name) and password can be given, but subsequentpool.getConnection()calls can specify a different user name to access that user’s schema.Heterogeneous pools cannot be used with the connection pool cache. Applications should ensure the pool object is explicitly passed between code modules, or use a homogeneous pool and make use of
connection.clientId.See Heterogeneous Connection Pools and Pool Proxy Authentication for details and examples.
Added in version 2.3.
httpsProxyString
Thin
The name or IP address of a proxy host to use for tunneling secure connections.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
httpsProxyPortNumber
Thin
The port to be used to communicate with the proxy host.
The default value is 0.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
machineString
Thin
The name of the host machine from where the connection originates. This is equivalent to the value in the
MACHINEcolumn of theV$SESSIONview.This optional property overrides the
oracledb.machineproperty.Added in version 6.7.
maxLifetimeSessionNumber
Both
The number of seconds that a pooled connection can exist in a pool after first being created. A value of 0 means there is no limit defined for the connection in a pool and no connections will be terminated. Connections become candidates for termination when they are acquired or released back to the pool, and have existed for longer than
maxLifetimeSessionseconds. Connections that are in active use will not be closed.In node-oracledb Thick mode, Oracle Client libraries 12.1 or later must be used. Note that when using node-oracledb in Thick mode with Oracle Client libraries prior to 21c, pool shrinkage is only initiated when the pool is accessed. So, pools in fully dormant applications will not shrink until the application is next used.
The default value is 0.
Added in version 6.9.
networkCompressionBoolean
Thin
Indicates if network data compression needs to be enabled or disabled for a database connection. Enabling data compression reduces the size of the Oracle Net Session Data Unit (SDU) that is to be sent over a connection.
The default value is false.
For node-oracledb Thick mode, network compression is enabled by setting the compression parameters in connect strings (Easy Connect string or a Connect Descriptor string). Alternatively, you can enable network compression by setting the SQLNET.COMPRESSION parameter in the sqlnet.ora network configuration file.
See Advanced Network Compression for more information.
Added in version 6.8.
networkCompressionThresholdNumber
Thin
The minimum data size, in bytes, for which compression should be performed on the Oracle Net Session Data Unit (SDU).
The default value is 1024 bytes.
The minimum data size is 200 bytes.
If this property is set to any value below 200, then the default value of 1024 bytes is taken as the networkCompressionThreshold value.
For node-oracledb Thick mode, network compression threshold can be set by using the SQLNET.COMPRESSION_THRESHOLD parameter in the sqlnet.ora network configuration file.
See Advanced Network Compression for more information.
Added in version 6.8.
osUserString
Thin
The name of the operating system user that initiates the database connection. This is equivalent to the value in the
OSUSERcolumn of theV$SESSIONview.This optional property overrides the
oracledb.osUserproperty.Added in version 6.7.
passwordString
Both
The password of the database user used by connections in the pool. A password is also necessary if a proxy user is specified at pool creation.
If
homogeneousis false, then the password may be omitted at pool creation but given in subsequentpool.getConnection()calls.poolAliasString
Both
An optional property that is used to explicitly add pools to the connection pool cache. If a pool alias is provided, then the new pool will be added to the connection pool cache and the
poolAliasvalue can then be used with methods that utilize the connection pool cache, such asoracledb.getPool()andoracledb.getConnection().See Connection Pool Cache for details and examples.
Added in version 1.11.
poolIncrementNumber
Both
The number of connections that are opened whenever a connection request exceeds the number of currently open connections.
The default value is 1.
This optional property overrides the
oracledb.poolIncrementproperty.poolMaxNumber
Both
The maximum number of connections to which a connection pool can grow.
The default value is 4.
This optional property overrides the
oracledb.poolMaxproperty.Importantly, if you increase
poolMaxyou should also increase the number of threads available to node-oracledb. See Connections and Number of Threads.See Connection Pooling for other pool sizing guidelines.
poolMaxPerShardNumber
Thick
Sets the maximum number of connections per shard for connection pools. This ensures that the pool is balanced towards each shard.
This optional property overrides the
oracledb.poolMaxPerShardproperty.Added in version 4.1.
poolMinNumber
Both
The number of connections established to the database when a pool is created. Also this is the minimum number of connections that a pool maintains when it shrinks.
The default value is 0.
This optional property overrides the
oracledb.poolMinproperty.poolPingIntervalNumber
Both
When a pool
pool.getConnection()is called and the connection has been idle in the pool for at leastpoolPingIntervalseconds, an internal “ping” will be performed first to check the validity of the connection.The default value is 60.
This optional property overrides the
oracledb.poolPingIntervalproperty.See Connection Pool Pinging for more information.
poolPingTimeoutNumber
Both
The number of milliseconds that a connection should wait for a response from
connection.ping(). Refer tooracledb.poolPingTimeoutfor details.The default value is 5000 milliseconds.
This optional property overrides the
oracledb.poolPingTimeoutproperty.See Connection Pool Pinging for more information.
Added in version 6.4.
poolTimeoutNumber
Both
The number of seconds after which idle connections (unused in the pool) may be terminated. Refer to
oracledb.poolTimeoutfor details.The default value is 60.
This optional property overrides the
oracledb.poolTimeoutproperty.privilegeNumber
Thin
The privilege to use when establishing a connection to the database. This optional property should be one of the privileged connection constants. All privileges must be specified individually except for
oracledb.SYSPRELIM.oracledb.SYSPRELIMis specified only for startup and shutdown calls and must be used in combination withSYSDBA(oracledb.SYSDBA | oracledb.SYSPRELIM) orSYSOPER(oracledb.SYOPER | oracledb.SYSPRELIM).See Privileged Connections for more information.
Added in version 6.5.1.
programString
Thin
The name of the program connecting to the database. This is equivalent to the value in the
PROGRAMcolumn of theV$SESSIONview.This optional property overrides the
oracledb.programproperty.Added in version 6.7.
queueMaxNumber
Both
The maximum number of pending
pool.getConnection()calls that can be queued.When the number of
pool.getConnection()calls that have been queued waiting for an available connection reachesqueueMax, then any futurepool.getConnection()calls will immediately return an error and will not be queued.If
queueMaxis -1, then the queue length is not limited.The default value is 500.
This optional property overrides the
oracledb.queueMaxproperty.Added in version 5.0.
queueRequestsNA
NA
This property was removed in node-oracledb 3.0 and queuing was always enabled. From node-oracledb 5.0, set
queueMaxto 0 to disable queuing. See Connection Pool Queue for more information.queueTimeoutNumber
Both
The number of milliseconds after which connection requests waiting in the connection request queue are terminated. If
queueTimeoutis set to 0, then queued connection requests are never terminated.The default value is 60000.
This optional property overrides the
oracledb.queueTimeoutproperty.retryCountNumber
Thin
The number of times that a connection attempt should be retried before the attempt is terminated.
The default value is 0.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
retryDelayNumber
Thin
The number of seconds to wait before making a new connection attempt.
The default value is 1.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Changed in version 6.7: The default value was changed from 0 seconds to 1 second.
Added in version 6.0.
sduNumber
Thin
The Oracle Net Session Data Unit (SDU) packet size in bytes. The database server configuration should also set this parameter.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
sessionCallbackString or Function
Both
If the
sessionCallbackis a callback function:function sessionCallback(Connection connection, String requestedTag, function callback(Error error, Connection connection){})
When
sessionCallbackis a Node.js function, eachpool.getConnection()will select a connection from the pool and may invokesessionCallbackbefore returning. ThesessionCallbackfunction is called:when the pool selects a brand new, never used connection in the pool.
if the pool selects a connection from the pool with a given tag but that tag string value does not match the connection’s current, actual tag. The tag requested (if any) by
pool.getConnection()is available in therequestedTagparameter. The actual tag in the connection selected by the pool is available inconnection.tag.
It will not be invoked for other
pool.getConnection()calls.The session callback is called before
pool.getConnection()returns so it can be used for logging or to efficiently set session state, such as with ALTER SESSION statements. Make sure any session state is set andconnection.tagis updated in thesessionCallbackfunction prior to it calling its owncallback()function otherwise the session will not be correctly set whengetConnection()returns. The connection passed intosessionCallbackshould be passed out throughcallback()so it is returned from the application’spool.getConnection()call.When node-oracledb Thick mode is using Oracle Client libraries 12.2 or later, tags are multi-property tags with name=value pairs like “k1=v1;k2=v2”.
When node-oracledb Thick mode is using Oracle Client libraries 12.2 or later,
sessionCallbackcan be a string containing the name of a PL/SQL procedure to be called whenpool.getConnection()requests a tag, and that tag does not match the connection’s actual tag. When the application uses DRCP connections, a PL/SQL callback can avoid the round-trip calls that a Node.js function would require to set session state. For non-DRCP connections, the PL/SQL callback will require a round-trip from the application.The PL/SQL procedure declaration is:
PROCEDURE mycallback ( desired_props IN VARCHAR2, actual_props IN VARCHAR2 );
See Connection Tagging and Session State for more information.
Added in version 3.1.
sodaMetaDataCacheBoolean
Thick
Indicates whether the pool’s connections should share a cache of SODA metadata. This improves SODA performance by reducing round-trips to the database when opening collections. It has no effect on non-SODA operations.
The default is false.
There is no global equivalent for setting this attribute. SODA metadata caching is restricted to pooled connections only.
Note that if the metadata of a collection is changed externally, the cache can get out of sync. If this happens, the cache can be cleared by calling
pool.reconfigure({sodaMetadataCache: false}). Seepool.reconfigure().A second call to
reconfigure()should then be made to re-enable the cache.Added in version 5.2.
It requires Oracle Client 21.3 (or later). The feature is also available in Oracle Client 19c from 19.11 onward.
sourceRouteString
Thin
Enables network routing through multiple protocol addresses. The value of this property can be ON or OFF.
The default value is ON.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
sslAllowWeakDNMatchBoolean
Thin
Enables the connection to use either a weaker or more secure DN matching behavior when the
sslServerDNMatchproperty is set.If the value is True, then the
sslServerDNMatchproperty uses a weaker DN matching behavior which only checks the server certificate (and not the listener certificate), and allows the service name to be used for partial DN matching. The DN matching for a partial match first matches the host name that the client connected to against the CN of the database server certificate DN or the SAN of the database server certificate. If this fails, then the service name is matched against the CN of the database server certificate DN.If the value is False, then the
sslServerDNMatchproperty uses a more secure DN matching behavior which checks both the listener and server certificates, and does not allow a service name check for partial DN matching. The DN matching for a partial match matches the host name that the client connected to against the CN of the certificate DN or the SAN of the certificate. The service name is not checked in this case.The default value is False.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.1.
sslServerCertDNString
Thin
The distinguished name (DN) that should be matched with the certificate DN. If not specified, a partial match is performed instead. A partial match matches the hostname that the client connected to against the common name (CN) of the certificate DN or the Subject Alternate Names (SAN) of the certificate.
This value is ignored if the
sslServerDNMatchproperty is not set to the value True.For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
sslServerDNMatchBoolean
Thin
Determines whether the server certificate DN should be matched in addition to the regular certificate verification that is performed.
If the
sslServerCertDNproperty is not provided, a partial DN match is performed instead. A partial match matches the hostname that the client connected to against the CN of the certificate DN or the SAN of the certificate.The default value is True.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
stmtCacheSizeNumber
Both
The number of statements to be cached in the statementcache of each connection in the pool.
This optional property overrides the
oracledb.stmtCacheSizeproperty.terminalString
Thin
The name of the terminal from where the connection originates. This is equivalent to the value in the
TERMINALcolumn of theV$SESSIONview.This optional property overrides the
oracledb.terminalproperty.Added in version 6.7.
tokenAuthConfigAzureObject
Both
A JavaScript object containing the Azure-specific parameters that need to be set when using the node-oracledb extensionAzure plugin with the support of Azure SDK for token generation. The properties of the
tokenAuthConfigAzureobject are detailed in createPool(): tokenAuthConfigAzure Object Properties. See Azure SDK Parameters for more information on these properties.When using OAuth 2.0 token-based authentication with node-oracledb Thick mode, Oracle Client libraries 19.15 (or later), or 21.7 (or later) must be used.
See OAuth 2.0 Token-Based Authentication for more information.
Added in version 6.8.
tokenAuthConfigOciObject
Both
A JavaScript object containing the OCI-specific parameters that need to be set when using the node-oracledb extensionOci plugin with the support of the OCI SDK for token generation. The properties of the
tokenAuthConfigOciobject are described in createPool(): tokenAuthConfigOci Object Properties. See OCI SDK Parameters for more information on these properties.When using IAM token-based authentication with node-oracledb Thick mode, Oracle Client libraries 19.14 (or later), or 21.5 (or later) must be used.
See IAM Token-Based Authentication for more information.
Added in version 6.8.
transportConnectTimeoutNumber
Thin
The maximum number of seconds to wait to establish a connection to the database host.
The default value is 20.0.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Changed in version 6.7: The default value was changed from 60.0 seconds to 20.0 seconds.
Added in version 6.0.
user,usernameString
Both
The two properties are aliases for each other. Use only one of the properties.
The database user name for connections in the pool. Can be a simple user name or a proxy of the form alison[fred]. See the Client Access Through a Proxy section in the Oracle Call Interface manual for more details about proxy authentication.
If
homogeneousis false, then the pool user name and password need to be specified only if the application wants that user to proxy the users supplied in subsequentpool.getConnection()calls.Added in version 5.2: The alias
username.useSNIBoolean
Thin
Enables the connection to use the TLS extension, Server Name Indication (SNI).
Usually, two TLS handshakes are required to establish a connection, one with the listener and the other with the server process. With useSNI, the connection information is sent in the SNI field which enables the listener to hand-off the connection to the appropriate server process without the listener having to perform a TLS handshake. SNI helps improve the connection establishment time. See the Configuring SNI for TLS Authentications section in the SQL*Net documentation for more details about SNI.
The default is False.
This property requires Oracle Database 23.7 (or later).
Added in version 6.8.
walletContentString
Thin
The security credentials required to establish a mutual TLS (mTLS) connection to Oracle Database. This property can be used to directly specify the security credentials instead of storing and reading the credentials from the
ewallet.pemfile specified in thewalletLocationproperty.The value of the
walletContentproperty overrides thewalletLocationvalue and theWALLET_LOCATIONparameter in the connection string.Added in version 6.6.
walletLocationString
Thin
The directory where the wallet can be found. In node-oracledb Thin mode, this must be the directory that contains the PEM-encoded wallet file.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
walletPasswordString
Thin
The password to decrypt the Privacy Enhanced Mail (PEM)-encoded private certificate, if it is encrypted.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
createPool(): accessToken Object Properties
The properties of the
accessTokenobject are:Table 1.28 createPool(): accessTokenObject AttributesAttribute
Description
tokenThe database authentication token.
privateKeyThe database authentication private key.
The
tokenandprivateKeyvalues can be obtained using various approaches. For example the Oracle Cloud Infrastructure Command Line Interface can be used.createPool(): refresh Parameter
The
refreshparameter values are:Table 1.29 createPool(): refreshParameter ValuesrefreshValueDescription
false
The application can return a token from an application-specific cache. If there is no cached token, the application must externally acquire one.
true
The token previously passed to driver is known to be expired, the application should externally acquire a new token.
createPool(): tokenAuthConfigOci Object Properties
The properties of the
tokenAuthConfigOciobject are:Table 1.30 createPool(): tokenAuthConfigOciObject PropertiesProperty
Description
Required or Optional
authTypeThe authentication type. The value should be the string configFileBasedAuthentication, simpleAuthentication, or instancePrincipal.
With Configuration File Based Authentication, the location of the configuration file containing the necessary information must be provided.
With Simple Authentication, the configuration parameters can be provided at runtime.
With Instance Principal Authentication, OCI compute instances can be authorized to access services on Oracle Cloud such as Oracle Autonomous Database. Node-oracledb applications running on such a compute instance are automatically authenticated, eliminating the need to provide database user credentials. This authentication method will only work on compute instances where internal network endpoints are reachable. See Instance Principal Authentication for more information.
See OCI SDK Authentication Methods for more information.
Required
profileThe configuration profile name. The default value is DEFAULT.
This property can be specified when the value of the
authTypeproperty is configFileBasedAuthentication.Optional
configFileLocationThe configuration file location. The default value is ~/.oci/config.
This property can be specified when the value of the
authTypeproperty is configFileBasedAuthentication.Optional
fingerprintFingerprint for the public key that was added for the user.
This property can be specified when the value of the
authTypeproperty is simpleAuthentication.Required
passphrasePassphrase used for the key, if it is encrypted.
This property can be specified when the value of the
authTypeproperty is simpleAuthentication.Optional
privateKeyLocationThe full path and file name of the private key.
For example, in Linux or macOS, the location of the private key can be ~/.oci/oci_api_key.pem. In Windows, the location can be %HOMEDRIVE%%HOMEPATH%.ocioci_api_key.pem.
This property can be specified when the value of the
authTypeproperty is simpleAuthentication.Required
regionIdThe ID of the Oracle Cloud Infrastructure region.
For example, us-ashburn-1.
This property can be specified when the value of the
authTypeproperty is simpleAuthentication.Required
tenancyOracle Cloud Identifier (OCID) of your tenancy.
For example, ocid1.tenancy.oc1..<unique_ID>.
This property can be specified when the value of the
authTypeproperty is simpleAuthentication.Required
userOCID of the user calling the API.
This property can be specified when the value of the
authTypeproperty is simpleAuthentication.Required
scopeThis property identifies all databases in the cloud tenancy of the authenticated user. The default value is urn:oracle:db::id::*.
A scope that authorizes access to all databases within a compartment has the format urn:oracle:db::id::<compartment-ocid>, for example, “urn:oracle:db::id::ocid1.compartment.oc1..xxxxxxxx”.
A scope that authorizes access to a single database within a compartment has the format urn:oracle:db::id::<compartment-ocid>::<database-ocid>, for example, “urn:oracle:db::id::ocid1.compartment.oc1..xxxxxx::ocid1.autonomousdatabase.oc1.phx.xxxxxx”.
This property can be specified when the value of the
authTypeproperty is simpleAuthentication, configFileBasedAuthentication, or instancePrincipal.Optional
createPool(): tokenAuthConfigAzure Object Properties
The properties of the
tokenAuthConfigAzureobject are:Table 1.31 createPool(): tokenAuthConfigAzureObject PropertiesProperty
Description
Required or Optional
authTypeThe authentication type. The authentication type for OAuth 2.0 is “azureServicePrincipal”. This type makes the plugin acquire Azure service principal access tokens through a client credential flow.
Required
authorityThis parameter must be set as a string in URI format with the tenant ID, for example,
https://{identity provider instance}/{tenantId}.The tenantId is the directory tenant the application plans to operate against in GUID or domain-name format.
Some of the common authority URLs are:
https://login.microsoftonline.com/<tenant>/ https://login.microsoftonline.com/common/ https://login.microsoftonline.com/organizations/ https://login.microsoftonline.com/consumers/
Required
clientIdThe application ID that is assigned to your application.
This information can be found in the portal where the application was registered.
Required
clientSecretThe client secret that was generated for your application in the application registration portal.
Required when using azureServicePrincipal
proxyThis property is to be set while using token generation behind a firewall.
Optional
scopesThis parameter represents the value of the scope for the request.
The value passed for this parameter should be the resource identifier (application ID URI) of the desired resource, with the “.default” suffix. For example,
https://{uri}/clientID/.default.All scopes included must be for a single resource. Specifying scopes for multiple resources will result in an error.
Required
Callback:
If you are using the callback programming style:
createPool(Object poolAttrs, function(Error error, Pool pool){});
See oracledb.createPool() Parameters for information on the
poolAttrsparameter.The parameters of the callback function
function(Error error, Pool pool)are:Callback Function Parameter
Description
Error
errorIf
createPool()succeeds,erroris NULL. If an error occurs, thenerrorcontains the error message.Pool
poolThe newly created connection pool. If
createPool()fails,poolwill be NULL. If the pool will be accessed via the pool cache, this parameter can be omitted. See Pool class for more information.
- oracledb.getConnection()
Promise:
promise = getConnection([String poolAlias | Object connAttrs]);
Obtains a connection from a pool in the connection pool cache or creates a new, standalone, non-pooled connection.
For situations where connections are used infrequently, creating a standalone connection may be more efficient than creating and managing a connection pool. However, in most cases, Oracle recommends getting connections from a
connection pool.Note: It is recommended to explicitly close a connection. If not, you may experience a short delay when the application terminates. This is due to the timing behavior of Node.js garbage collection which needs to free the connection reference.
The following table shows the various signatures that can be used when invoking
getConnectionand describes how the function will behave as a result.Signature
Description
oracledb.getConnection()Gets a connection from the previously created default pool. Returns a promise.
oracledb.getConnection(callback)Gets a connection from the previously created default pool. Invokes the callback.
oracledb.getConnection(poolAlias)Gets a connection from the previously created pool with the specified
poolAlias. Returns a promise.oracledb.getConnection(poolAlias, callback)Gets a connection from the previously created pool with the specified
poolAlias. Invokes the callback.oracledb.getConnection(connAttrs)Creates a standalone, non-pooled connection. Returns a promise.
oracledb.getConnection(connAttrs, callback)Creates a standalone, non-pooled connection. Invokes the callback.
Note if the application opens a number of connections, you should increase the number of threads available to node-oracledb. See Connections and Number of Threads.
From node-oracledb 3.1.0, a non-pooled
oracledb.getConnection()call will return a DPI-1047 error if node-oracledb cannot load Oracle Client libraries. Previous versions threw this error fromrequire('oracledb').See Connection Handling for more information on connections.
The parameters of the
oracledb.getConnection()method are:Table 1.32 oracledb.getConnection() Parameters Parameter
Data Type
Description
poolAliasString
Specifies which previously created pool in the connection pool cache to use to obtain the connection.
connAttrsObject
The
connAttrsparameter object provides connection credentials and connection-specific configuration properties.Any
connAttrsproperties that are not used by thegetConnection()method are ignored.See getConnection(): connAttrs Parameter Properties for information on the properties of the
connAttrsobject.The properties of the
connAttrsobject are:Table 1.33 getConnection(): connAttrsParameter PropertiesProperty
Data Type
node-oracledb Mode
Description
accessTokenFunction, String, or Object
Both
For Microsoft Azure Active Directory OAuth 2.0 token-based authentication,
accessTokencan be:a callback function returning the token as a string
or the token as a string
For OAuth 2.0, tokens can be obtained using various approaches. For example, using the Azure Active Directory API.
For Oracle Cloud Infrastructure Identity and Access Management (IAM) token-based authentication,
accessTokencan be:an object containing
tokenandprivateKeyattributesor a callback function returning an object containing
tokenandprivateKeyattributes
For OCI IAM, the
tokenandprivateKeyvalues can be obtained using various approaches. For example the Oracle Cloud Infrastructure Command Line Interface can be used.The properties of the
accessTokenobject are described in getConnection(): accessToken Object Properties.If
accessTokenis a callback function:function accessToken(boolean refresh, object accessTokenConfig)
When
accessTokenis a callback function, the returned token is used by node-oracledb for authentication. Therefreshparameter is described in getConnection(): refresh Parameter Values. See accessTokenConfig for information on this parameter.For each connection, the callback is invoked with the
refreshparameter set to false. This indicates that the application can provide a token from its own application managed cache, or it can generate a new token if there is no cached value. Node-oracledb checks whether the returned token has expired. If it has expired, then the callback function will be invoked a second time withrefreshset to true. In this case, the function must externally acquire a token, optionally add it to the application’s cache, and return the token.For token-based authentication, the
externalAuthconnection attribute must be set to true. Theuser(orusername) andpasswordattributes should not be set.See Token-Based Authentication for more information.
Added in version 5.4: The
accessTokenproperty was added to support IAM token-based authentication. For IAM token-based authentication, this property must be an Object. For node-oracledb Thick mode, Oracle Client libraries 19.14 (or later), or 21.5 (or later) must be used for IAM token-based authentication.Changed in version 5.5: The
accessTokenproperty was extended to allow OAuth 2.0 token-based authentication in node-oracledb 5.5. For OAuth 2.0, the property should be a string, or a callback. For node-oracledb Thick mode, Oracle Client libraries 19.15 (or later), or 21.7 (or later) must be used. The callback usage supports both OAuth 2.0 and IAM token-based authentication.accessTokenConfigObject
Both
An object containing the Azure-specific or OCI-specific parameters that need to be set when using the Azure Software Development Kit (SDK) or Oracle Cloud Infrastructure (OCI) SDK for token generation. This property should only be specified when the accessToken property is a callback function. For more information on the Azure-specific parameters, see sampleazuretokenauth.js and for the OCI-specific parameters, see sampleocitokenauth.js.
For OAuth2.0 token-based authentication and when using node-oracledb Thick mode, Oracle Client libraries 19.15 (or later), or 21.7 (or later) must be used. For IAM token-based authentication and when using node-oracledb Thick mode, Oracle Client libraries 19.14 (or later), or 21.5 (or later) are required.
Added in version 6.3.
appContextArray
Both
An array of array values that identifies the application context used by the connection. The elements of the array should contain three string values - namespace, name, and value. See Application Contexts.
Added in version 6.9.
configDirString
Thin
The directory in which the Optional Oracle Net Configuration Files are found.
For node-oracledb Thick mode, use the
oracledb.initOracleClient()option configDir instead.Added in version 6.0.
connectionIdPrefixString
Thin
The application specific prefix parameter that is added to the connection identifier.
Added in version 6.0.
connectString,connectionStringString
Both
The Oracle database instance to connect to. The string can be an Easy Connect string, or a Net Service Name from a
tnsnames.orafile, or the name of a local Oracle database instance. See Oracle Net Services Connection String for examples.The two properties are aliases for each other. Use only one of the properties.
Added in version 2.1: The alias
connectionStringwas added.connectTimeoutNumber
Thin
The timeout duration in seconds for an application to establish an Oracle Net connection.
There is no timeout by default.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
debugJdwpString
Thin
Specifies the host and port of the PL/SQL debugger with the format host=<host>;port=<port>. This allows using the Java Debug Wire Protocol (JDWP) to debug PL/SQL code called by node-oracledb.
The default value is the value of environment variable
ORA_DEBUG_JDWP.For node-oracledb Thick mode, set the
ORA_DEBUG_JDWPenvironment variable with the same syntax instead. See Application Tracing.Added in version 6.0.
driverNameString
Thin
The name of the driver that is used by the client to connect to Oracle Database. This is equivalent to the value in the
CLIENT_DRIVERcolumn of theV$SESSION_CONNECT_INFOview.This optional property overrides the
oracledb.driverNameproperty.Added in version 6.7.
editionString
Both
Sets the name used for Edition-Based Redefinition by this connection.
This optional property overrides the
oracledb.editionproperty.Changed in version 6.8: Support for this property was added in node-oracledb Thin mode.
Added in version 2.2.
eventsBoolean
Thick
Determines if the standalone connection is created using Oracle Call Interface events mode.
This optional property overrides the
oracledb.eventsproperty.Added in version 2.2.
expireTimeNumber
Thin
The number of minutes between the sending of keepalive probes. If this property is set to a value greater than zero, it enables the keepalive probes.
The default value is 0.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
externalAuthBoolean
Both
If this optional property is set to true in Thick mode, then the connection will be established using External Authentication.
In Thin mode, when token-based authentication or external authentication using TLS is required, this property must be set to true. In all the other cases where this property is set to true, an error is thrown.
This optional property overrides the
oracledb.externalAuthproperty.The
user(orusername) andpasswordproperties should not be set whenexternalAuthis true.Note prior to node-oracledb 0.5 this property was called
isExternalAuth.httpsProxyString
Thin
The name or IP address of a proxy host to use for tunneling secure connections.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
httpsProxyPortNumber
Thin
The port to be used to communicate with the proxy host.
The default value is 0.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
machineString
Thin
The name of the host machine from where the connection originates. This is equivalent to the value in the
MACHINEcolumn of theV$SESSIONview.This optional property overrides the
oracledb.machineproperty.Added in version 6.7.
matchAnyBoolean
Thick
Used in conjunction with tag when getting a connection from a connection pool.
Indicates that the tag in a connection returned from a connection pool may not match the requested tag.
See Connection Tagging and Session State.
Added in version 3.1.
networkCompressionBoolean
Thin
Indicates if network data compression needs to be enabled or disabled for a database connection. Enabling data compression reduces the size of the Oracle Net Session Data Unit (SDU) that is to be sent over a connection.
The default value is false.
For node-oracledb Thick mode, network compression is enabled by setting the compression parameters in connect strings (Easy Connect string or a Connect Descriptor string). Alternatively, you can enable network compression by setting the SQLNET.COMPRESSION parameter in the sqlnet.ora network configuration file.
See Advanced Network Compression for more information.
Added in version 6.8.
networkCompressionThresholdNumber
Thin
The minimum data size, in bytes, for which compression should be performed on the Oracle Net Session Data Unit (SDU).
The default value is 1024 bytes.
The minimum data size is 200 bytes.
If this property is set to any value below 200, then the default value of 1024 bytes is taken as the networkCompressionThreshold value.
For node-oracledb Thick mode, network compression threshold can be set by using the SQLNET.COMPRESSION_THRESHOLD parameter in the sqlnet.ora network configuration file.
See Advanced Network Compression for more information.
Added in version 6.8.
newPasswordString
Both
The new password to use for the database user. When using
newPassword, the password property should be set to the current password.This allows passwords to be changed at the time of connection, in particular it can be used to connect when the old password has expired.
See Changing Passwords and Connecting with an Expired Password.
Added in version 2.2.
osUserString
Thin
The name of the operating system user that initiates the database connection. This is equivalent to the value in the
OSUSERcolumn of theV$SESSIONview.This optional property overrides the
oracledb.osUserproperty.Added in version 6.7.
passwordString
Both
The password of the database user. A password is also necessary if a proxy user is specified.
poolAliasString
Both
Specifies which previously created pool in the connection pool cache to obtain the connection from. See Pool Alias.
privilegeNumber
Both
The privilege to use when establishing connection to the database. This optional property should be one of the privileged connection constants. All privileges must be specified individually except for
oracledb.SYSPRELIM.oracledb.SYSPRELIMis specified only for startup and shutdown calls and must be used in combination withSYSDBA(oracledb.SYSDBA | oracledb.SYSPRELIM) orSYSOPER(oracledb.SYOPER | oracledb.SYSPRELIM).See Privileged Connections for more information.
Added in version 2.1.
Changed in version 6.5.1: The database privilege can be specified for pooled connections.
programString
Thin
The name of the program connecting to the database. This is equivalent to the value in the
PROGRAMcolumn of theV$SESSIONview.This optional property overrides the
oracledb.programproperty.Added in version 6.7.
retryCountNumber
Thin
The number of times that a connection attempt should be retried before the attempt is terminated.
The default value is 0.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
retryDelayNumber
Thin
The number of seconds to wait before making a new connection attempt.
The default value is 1.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Changed in version 6.7: The default value was changed from 0 seconds to 1 second.
Added in version 6.0.
sduNumber
Thin
The Oracle Net Session Data Unit (SDU) packet size in bytes. The database server configuration should also set this parameter.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
shardingKeyArray
Thick
Allows a connection to be established directly to a database shard. See Connecting to Oracle Globally Distributed Database.
Array values may be of String type (mapping to VARCHAR2 sharding keys), Number (NUMBER), Date (DATE), or Buffer (RAW). Multiple types may be used in the array. Sharding keys TIMESTAMP type are not supported.
Added in version 4.1.
sourceRouteString
Thin
Enables network routing through multiple protocol addresses. The value of this property can be ON or OFF.
The default value is ON.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
sslAllowWeakDNMatchBoolean
Thin
Enables the connection to use either a weaker or more secure DN matching behavior when the
sslServerDNMatchproperty is set.If the value is True, then the
sslServerDNMatchproperty uses a weaker DN matching behavior which only checks the server certificate (and not the listener certificate), and allows the service name to be used for partial DN matching. The DN matching for a partial match first matches the host name that the client connected to against the common name (CN) of the database server certificate DN or the Subject Alternate Names (SAN) of the database server certificate. If this fails, then the service name is matched against the CN of the database server certificate DN.If the value is False, then the
sslServerDNMatchproperty uses a more secure DN matching behavior which checks both the listener and server certificates, and does not allow a service name check for partial DN matching. The DN matching for a partial match matches the host name that the client connected to against the CN of the certificate DN or the SAN of the certificate. The service name is not checked in this case.The default value is False.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.1.
sslServerCertDNString
Thin
The distinguished name (DN) that should be matched with the certificate DN. If not specified, a partial match is performed instead. A partial match matches the hostname that the client connected to against the common name (CN) of the certificate DN or the Subject Alternate Names (SAN) of the certificate.
This value is ignored if the
sslServerDNMatchproperty is not set to the value True.For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
sslServerDNMatchBoolean
Thin
Determines whether the server certificate DN should be matched in addition to the regular certificate verification that is performed.
If the
sslServerCertDNproperty is not provided, a partial DN match is performed instead. A partial match matches the hostname that the client connected to against the CN of the certificate DN or the SAN of the certificate.The default value is True.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
stmtCacheSizeNumber
Both
The number of statements to be cached in the statement cache of each connection. This optional property may be used to override the
oracledb.stmtCacheSizeproperty.superShardingKeyArray
Thick
Allows a connection to be established directly to a database shard. See Connecting to Oracle Globally Distributed Database.
Array values may be of String type (mapping to VARCHAR2 sharding keys), Number (NUMBER), Date (DATE), or Buffer (RAW). Multiple types may be used in the array. Sharding keys TIMESTAMP type are not supported.
Added in version 4.1.
tagString
Thick
Used when getting a connection from a connection pool.
Indicates the tag that a connection returned from a connection pool should have. Various heuristics determine the tag that is actually returned, see Connection Tagging and Session State.
Added in version 3.1.
terminalString
Thin
The name of the terminal from where the connection originates. This is equivalent to the value in the
TERMINALcolumn of theV$SESSIONview.This optional property overrides the
oracledb.terminalproperty.Added in version 6.7.
tokenAuthConfigAzureObject
Both
A JavaScript object containing the Azure-specific parameters that need to be set when using the node-oracledb extensionAzure plugin with the support of Azure SDK for token generation. The properties of the
tokenAuthConfigAzureobject are detailed in getConnection(): tokenAuthConfigAzure Object Properties. See Azure SDK Parameters for more information on these properties.When using OAuth 2.0 token-based authentication with node-oracledb Thick mode, Oracle Client libraries 19.15 (or later), or 21.7 (or later) must be used.
See OAuth 2.0 Token-Based Authentication for more information.
Added in version 6.8.
tokenAuthConfigOciObject
Both
A JavaScript object containing the OCI-specific parameters that need to be set when using the node-oracledb extensionOci plugin with the support of the OCI SDK for token generation. The properties of the
tokenAuthConfigOciobject are described in getConnection(): tokenAuthConfigOci Properties. See OCI SDK Parameters for more information on these properties.When using IAM token-based authentication with node-oracledb Thick mode, Oracle Client libraries 19.14 (or later), or 21.5 (or later) must be used.
See IAM Token-Based Authentication for more information.
Added in version 6.8.
transportConnectTimeoutNumber
Thin
The maximum number of seconds to wait to establish a connection to the database host.
The default value is 20.0.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Changed in version 6.7: The default value was changed from 60.0 seconds to 20.0 seconds.
Added in version 6.0.
user,usernameString
Both
The two properties are aliases for each other. Use only one of the properties.
The database user name. Can be a simple user name or a proxy of the form alison[fred]. See the Client Access Through a Proxy section in the Oracle Call Interface manual for more details about proxy authentication.
Added in version 5.2: The alias
username.useSNIBoolean
Thin
Enables the connection to use the TLS extension, Server Name Indication (SNI).
Usually, two TLS handshakes are required to establish a connection, one with the listener and the other with the server process. With useSNI, the connection information is sent in the SNI field which enables the listener to hand-off the connection to the appropriate server process without the listener having to perform a TLS handshake. SNI helps improve the connection establishment time. See the Configuring SNI for TLS Authentications section in the SQL*Net documentation for more details about SNI.
The default is False.
This property requires Oracle Database 23.7 (or later).
Added in version 6.8.
walletContentString
Thin
The security credentials required to establish a mutual TLS (mTLS) connection to Oracle Database. This property can be used to directly specify the security credentials instead of storing and reading the credentials from the
ewallet.pemfile specified in thewalletLocationproperty.The value of the
walletContentproperty overrides thewalletLocationvalue and theWALLET_LOCATIONparameter in the connection string.Added in version 6.6.
walletLocationString
Thin
The directory where the wallet can be found. In node-oracledb Thin mode, this must be the directory that contains the PEM-encoded wallet file.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
walletPasswordString
Thin
The password to decrypt the Privacy Enhanced Mail (PEM)-encoded private certificate, if it is encrypted.
For node-oracledb Thick mode, use an Easy Connect string or a Connect Descriptor string instead.
Added in version 6.0.
getConnection(): accessToken Object Properties
The properties of the
accessTokenobject are described below.Table 1.34 getConnection(): accessTokenObject PropertiesAttribute
Description
tokenThe database authentication token.
privateKeyThe database authentication private key.
getConnection(): refresh Parameter
Table 1.35 getConnection(): refreshParameter ValuesrefreshValueDescription
false
The application can return a token from an application-specific cache. If there is no cached token, the application must externally acquire one.
true
The token previously passed to driver is known to be expired, the application should externally acquire a new token.
getConnection(): tokenAuthConfigOci Object Properties
The properties of the
tokenAuthConfigOciobject are:Table 1.36 getConnection(): tokenAuthConfigOciPropertiesProperty
Description
Required or Optional
authTypeThe authentication type. The value should be the string configFileBasedAuthentication or simpleAuthentication.
In Configuration File Based Authentication, the location of the configuration file containing the necessary information must be provided.
In Simple Authentication, the configuration parameters can be provided at runtime.
Required
profileThe configuration profile name. The default value is DEFAULT.
This property can be specified when the value of the
authTypeproperty is configFileBasedAuthentication.Optional
configFileLocationThe configuration file location. The default value is ~/.oci/config.
This property can be specified when the value of the
authTypeproperty is configFileBasedAuthentication.Optional
fingerprintFingerprint for the public key that was added for the user.
This property can be specified when the value of the
authTypeproperty is simpleAuthentication.Required
passphrasePassphrase used for the key, if it is encrypted.
This property can be specified when the value of the
authTypeproperty is simpleAuthentication.Optional
privateKeyLocationThe full path and file name of the private key.
For example, in Linux or macOS, the location of the private key can be ~/.oci/oci_api_key.pem. In Windows, the location can be %HOMEDRIVE%%HOMEPATH%.ocioci_api_key.pem.
This property can be specified when the value of the
authTypeproperty is simpleAuthentication.Required
regionIdThe ID of the Oracle Cloud Infrastructure region.
For example, us-ashburn-1.
This property can be specified when the value of the
authTypeproperty is simpleAuthentication.Required
tenancyOracle Cloud Identifier (OCID) of your tenancy.
For example, ocid1.tenancy.oc1..<unique_ID>.
This property can be specified when the value of the
authTypeproperty is simpleAuthentication.Required
userOCID of the user calling the API.
This property can be specified when the value of the
authTypeproperty is simpleAuthentication.Required
getConnection(): tokenAuthConfigAzure Object Properties
The properties of the
tokenAuthConfigAzureobject are:Table 1.37 getConnection(): tokenAuthConfigAzureObject PropertiesProperty
Description
Required or Optional
authTypeThe authentication type. The authentication type for OAuth 2.0 is “azureServicePrincipal”. This type makes the plugin acquire Azure service principal access tokens through a client credential flow.
Required
authorityThis parameter must be set as a string in URI format with the tenant ID, for example,
https://{identity provider instance}/{tenantId}.The tenantId is the directory tenant the application plans to operate against in GUID or domain-name format.
Some of the common authority URLs are:
https://login.microsoftonline.com/<tenant>/ https://login.microsoftonline.com/common/ https://login.microsoftonline.com/organizations/ https://login.microsoftonline.com/consumers/
Required
clientIdThe application ID that is assigned to your application.
This information can be found in the portal where the application was registered.
Required
clientSecretThe client secret that was generated for your application in the application registration portal.
Required when using azureServicePrincipal
proxyThis property is to be set while using token generation behind a firewall.
Optional
scopesThis parameter represents the value of the scope for the request.
The value passed for this parameter should be the resource identifier (application ID URI) of the desired resource, with the “.default” suffix. For example,
https://{uri}/clientID/.default.All scopes included must be for a single resource. Specifying scopes for multiple resources will result in an error.
Required
Callback:
If you are using the callback programming style:
getConnection([String poolAlias | Object connAttrs], function(Error error, Connection connection){});
See oracledb.getConnection() Parameters for information on the
poolAliasandconnAttrsparameters.The parameters of the callback function
function(Error error, Connection connection)are:Callback Function Parameter
Description
Error
errorIf
getConnection()succeeds,erroris NULL. If an error occurs, thenerrorcontains the error message.Connection
connectionThe newly created connection. If
getConnection()fails, connection will be NULL. See Connection class for more details.
- oracledb.getNetworkServiceNames()
Added in version 6.7.
promise = getNetworkServiceNames(String configDir);
Returns a list of TNS Aliases, also known as Network Service Names, defined in the tnsnames.ora file which is inside the directory that is specified in the
configDirproperty or theTNS_ADMINenvironment variable ifconfigDiris not specified. If atnsnames.orafile does not exist, then an exception is raised.The parameters of the
oracledb.getNetworkServiceNames()method are:Table 1.38 oracledb.getNetworkServiceNames() Parameters Parameter
Data Type
Description
configDirString
The directory in which the tnsnames.ora file resides.
If
configDiris not specified, then thetnsnames.orafile is searched for in the directory specified in theTNS_ADMINOracle environment variable.
- oracledb.getPool()
getPool([String poolAlias]);
Retrieves a previously created pool from the connection pool cache. Note that this is a synchronous method.
The parameters of the
oracledb.getPool()method are:Table 1.39 oracledb.getPool() Parameters Parameter
Data Type
Description
aliasString
The pool alias of the pool to retrieve from the connection pool cache. The default value is ‘default’ which will retrieve the default pool from the cache.
- oracledb.initOracleClient()
Added in version 5.0.
initOracleClient([Object options]);
From node-oracledb 6.0, this synchronous function enables node-oracledb Thick mode by initializing the Oracle Client library (see Enabling node-oracledb Thick Mode). This method must be called before any standalone connection or pool is created. If a connection or pool is first created in Thin mode, then
initOracleClient()will raise an exception and Thick mode will not be enabled. If the first call toinitOracleClient()had an incorrect path specified, then a second call with the correct path will work. TheinitOracleClient()method can be called multiple times in each Node.js process as long as the arguments are the same each time.In node-oracledb 5.5 and earlier versions, this synchronous function loads and initializes the Oracle Client libraries that are necessary for node-oracledb to communicate with Oracle Database. This function is optional. If used, it should be the first node-oracledb call made by an application. If
initOracleClient()is not called, then the Oracle Client libraries are loaded at the time of first use in the application, such as when creating a connection pool. The default values described for options will be used in this case. If the Oracle Client libraries cannot be loaded, or they have already been initialized, either by a previous call to this function or because another function call already required the Oracle Client libraries, theninitOracleClient()raises an exception.See Initializing node-oracledb for more information.
The parameters of the
oracledb.initOracleClient()method are:Table 1.40 oracledb.initOracleClient() Parameters Parameter
Data Type
Description
optionsObject
The options parameter and option attributes are optional. If an attribute is set, it should be a string value. See initOracleClient(): options Parameter Attributes for information on the
optionsattributes.The properties of the
optionsparameter are:Table 1.41 initOracleClient(): optionsParameter AttributesAttribute
Description
binaryDirThis directory is added to the start of the default search path used by
initOracleClient()to load the node-oracledb Thick mode binary module.The default search path includes
node_modules/oracledb/build/Releaseandnode_modules/oracledb/build/Debug.Added in version 6.2.
configDirThis specifies the directory in which the Optional Oracle Net Configuration and Optional Oracle Client Configuration files reside.
It is equivalent to setting the Oracle environment variable
TNS_ADMINto this value. Any value in that environment variable prior to the call tooracledb.initOracleClient()is ignored. On Windows, remember to double each backslash used as a directory separator.If
configDiris not set, Oracle’s default configuration file search heuristics are used.driverNameThis specifies the driver name value shown in database views, such as
V$SESSION_CONNECT_INFO.It can be used by applications to identify themselves for tracing and monitoring purposes. The convention is to separate the product name from the product version by a colon and single space characters.
If this attribute is not specified, then the default value in node-oracledb Thick mode is like “node-oracledb thk : version”. See Other Node-oracledb Initialization.
errorUrlThis specifies the URL that is included in the node-oracledb exception message if the Oracle Client libraries cannot be loaded.
This allows applications that use node-oracledb to refer users to application-specific installation instructions.
If this attribute is not specified, then the node-oracledb installation instructions are used. See Other Node-oracledb Initialization.
libDirThis specifies the directory containing the Oracle Client libraries.
If
libDiris not specified, the default library search mechanism is used.If your client libraries are in a full Oracle Client or Oracle Database installation, such as Oracle Database “XE” Express Edition, then you must have previously set environment variables like
ORACLE_HOMEbefore callinginitOracleClient(). On Windows, remember to double each backslash used as a directory separator. See Locating the Oracle Client Libraries.On Linux, ensure a
libclntsh.sofile exists. On macOS ensure alibclntsh.dylibfile exists. Node-oracledb will not directly loadlibclntsh.*.XX.1files inlibDir. Note other libraries used bylibclntsh*are also required.On Linux, using
libDiris only useful for forcinginitOracleClient()to immediately load the Oracle Client libraries because those libraries still need to be in the operating system search path, such as from runningldconfigor set in the environment variableLD_LIBRARY_PATH.
- oracledb.registerConfigurationProviderHook()
Added in version 6.9.
registerConfigurationProviderHook(String configProvider, Function fn)
Registers the centralized configuration provider extension modules. These registered modules will be called and executed during standalone and pool connection creation.
If you have defined your own extension module for any particular centralized configuration provider, you need to register it using this method in your code.
The parameters of the
oracledb.registerConfigurationProviderHook()method are:Table 1.42 oracledb.registerConfigurationProviderHook() Parameters Parameter
Data Type
Description
configProviderString
The centralized configuration provider extension that needs to be accessed. The value can be the string “ociobject”, “ocivault”, “azure”, or “azurevault” which are the pre-supplied node-oracledb configuration provider extensions.
fnFunction
The hook function that needs to be registered. This hook function will be invoked when
oracledb.getConnection()ororacledb.createPool()are called. The user hook function is expected to return the configuration information from the configuration provider specified in theconfigProviderparameter.See Using Centralized Configuration Provider Hook Functions.
- oracledb.registerProcessConfigurationHook()
Added in version 6.8.
registerProcessConfigurationHook(Function fn)
Registers extension modules. These registered modules will be called and executed during standalone and pool connection creation.
The parameters of the
registerProcessConfigurationHook()method are:Table 1.43 oracledb.registerProcessConfigurationHook() Parameters Parameter
Data Type
Description
fnFunction
The user hook function that needs to be registered. This hook function will be invoked when
oracledb.getConnection()ororacledb.createPool()are called. The user hook function is expected to return an accessToken that needs to be registered.
- oracledb.shutdown()
Added in version 5.0.
Promise:
promise = shutdown([Object connAttr [, Number shutdownMode]]);
This is the simplified form of
connection.shutdown()used for shutting down a database instance. It accepts connection credentials and shuts the database instance completely down.Note
This method is only supported in node-oracledb Thick mode. See Enabling node-oracledb Thick Mode.
Internally it creates, and closes, a standalone connection using the oracledb.SYSOPER privilege.
See Database Start Up and Shut Down.
The parameters of the
oracledb.shutdown()method are:Table 1.44 oracledb.shutdown() Parameters Parameter
Data Type
Description
connAttrObject
Connection credentials similar to oracledb.getConnection() credentials. The properties
user,usernamepassword,connectString,connectionString, andexternalAuthmay be specified.shutdownModeNumber
oracledb.SHUTDOWN_MODE_ABORT, oracledb.SHUTDOWN_MODE_DEFAULT, oracledb.SHUTDOWN_MODE_IMMEDIATE, oracledb.SHUTDOWN_MODE_TRANSACTIONAL, or oracledb.SHUTDOWN_MODE_TRANSACTIONAL_LOCAL.
The default mode is oracledb.SHUTDOWN_MODE_DEFAULT.
Callback:
If you are using the callback programming style:
shutdown([Object connAttr, [Number shutdownMode, ] ] function(Error error) {});
See oracledb.shutdown() Parameters for information on the parameters.
The parameters of the callback function
function(Error error)are:Callback Function Parameter
Description
Error
errorIf
shutdown()succeeds,erroris NULL. If an error occurs, thenerrorcontains the error message.
- oracledb.startup()
Added in version 5.0.
Promise:
promise = startup([Object connAttrs [, Object options ]]);
This is the simplified form of
connection.startup()used for starting a database instance up. It accepts connection credentials and starts the database instance completely.Note
This method is only supported in node-oracledb Thick mode. See Enabling node-oracledb Thick Mode.
As part of the start up process, a standalone connection using the oracledb.SYSOPER privilege is internally created and closed.
See Database Start Up and Shut Down.
The parameters of the
oracledb.startup()method are:Table 1.45 oracledb.startup() Parameters Parameter
Data Type
Description
connAttrObject
Connection credentials similar to oracledb.getConnection() credentials. The properties
username,password,connectString,connectionString, andexternalAuthmay be specified.optionsObject
The optional
optionsobject can contain one or more of the properties listed in startup(): options Parameter Properties.The properties of the
optionsproperty are:Table 1.46 startup(): optionsParameter PropertiesAttribute
Data Type
Description
forceBoolean
Shuts down a running database using oracledb.SHUTDOWN_MODE_ABORT before restarting the database. The database start up may require instance recovery. The default for
forceis false.restrictBoolean
After the database is started, access is restricted to users who have the CREATE_SESSION and RESTRICTED SESSION privileges. The default is false.
pfileString
The path and filename for a text file containing Oracle Database initialization parameters. If
pfileis not set, then the database server-side parameter file is used.Callback:
If you are using the callback programming style:
startup([Object connAttrs, [Object options, ] ] function(Error error) {});
See oracledb.startup() Parameters for information on the
connAttrsandoptionsparameters.The parameters of the callback function
function(Error error)are:Callback function parameter
Description
Error
errorIf
startup()succeeds,erroris NULL. If an error occurs, thenerrorcontains the error message.
1.4. Oracledb SparseVector Class
Added in version 6.8.
A SparseVector Class stores information about a sparse vector. This class represents an object that accepts one of the following types in its constructor: typed array, JavaScript array, object, or string. See Using SPARSE Vectors for more information.
1.4.1. SparseVector Properties
- SparseVector.indices
This property is a JavaScript array or a 32-bit unsigned integer (Uint32Array) TypedArray that specifies the indices (zero-based) of non-zero values in the vector.
- SparseVector.numDimensions
This property is an integer that specifies the number of dimensions of the vector.
- SparseVector.values
This property is a JavaScript array or TypedArray that specifies the non-zero values stored in the vector.
1.4.2. SparseVector Methods
- SparseVector.dense()
Converts a sparse vector to a dense vector and returns a TypedArray of 8-bit signed integers, 32-bit floating-point numbers, or 64-bit floating-point numbers depending on the storage format of the sparse vector column’s non-zero values in Oracle Database.
This method is best used with sparse vectors read from Oracle Database.
1.5. Oracledb Future Object
A special object that contains properties which control the behavior of node-oracledb, allowing use of new features.
Added in version 6.3.
- oracledb.future.oldJsonColumnAsObj
This property is a boolean which when set to true while using Oracle Database 12c (or later), fetches VARCHAR2 and LOB columns that were created with the
IS JSONconstraint in the same way that columns of type JSON are fetched when using Oracle Database 21c (or later). TheIS JSONconstraint that is specified when creating VARCHAR2 and LOB columns ensures that only JSON data is stored in these columns.Also, BLOB columns that were created with the
IS JSON FORMAT OSONcheck constraint are fetched in the same way as columns of type JSON when this property is set to true. Node-oracledb Thick mode requires Oracle Client 21c (or later).The default value is false.
In a future version of node-oracledb, the setting of this attribute will no longer be required since this will be the default behavior.
Added in version 6.3.
Changed in version 6.4: BLOB columns with the
IS JSON FORMAT OSONcheck constraint enabled can now be fetched as JSON type columns when this property is set.
1.6. Oracledb IntervalYM Class
Objects of this class are returned for columns of type INTERVAL YEAR TO MONTH and can be passed to variables of type oracledb.DB_TYPE_INTERVAL_YM The class contains two optional integer attributes, years and months. These attributes can be set by a passed-in JavaScript object containing these attributes.
If no JavaScript object is passed in or if these attributes are not defined in the passed-in JavaScript object, they are set to 0 by default.
If these attribute values are not integers, then the NJS-007 error is thrown when the object is being created.
Added in version 6.8.
1.7. Oracledb IntervalDS Class
Objects of this class are returned for columns of type INTERVAL DAY TO SECOND and can be passed to variables of type oracledb.DB_TYPE_INTERVAL_DS The class contains five optional integer attributes, days, hours, minutes, seconds, and fseconds (fractional seconds denoted in nanoseconds). These attributes can be set by a passed-in JavaScript object containing these attributes.
If no JavaScript object is passed in or if these attributes are not defined in the passed-in JavaScript object, they are set to 0 by default.
If these attribute values are not integers, then the NJS-007 error is thrown when the object is being created.
Added in version 6.8.
1.8. Oracledb JsonId Class
Objects of this class are returned by SODA in the _id attribute of documents stored in native collections when using Oracle Database 23.4 (or later). The JsonId class is a subclass of Uint8Array and can be instantiated in the same way as an Uint8Array datatype object.
Added in version 6.5.
1.9. Oracledb TraceHandler Interface
The TraceHandlerBase class acts as an interface which provides abstract methods that can be implemented by derived classes. The implemented methods can use the traceContext in/out parameter with OpenTelemetry.
Added in version 6.7.
1.9.1. TraceHandlerBase Class
1.9.1.1. TraceHandlerBase Methods
- traceHandlerBase.disable()
disable();
Disables invoking the Abstract methods with traceContext data. Note that this is a synchronous method.
- traceHandlerBase.enable()
enable();
Enables invoking the Abstract methods with traceContext data. Note that this is a synchronous method.
- traceHandlerBase.isEnabled()
isEnabled();
Determines if the abstract methods will be invoked.
- onEnterFn()
onEnterFn(Object traceContext);
This method is invoked before a public method passes the traceContext. Note that this is a synchronous method.
Table 1.47 onEnterFn() Parameters Parameter
Data Type
Description
traceContextObject
The trace context details. This includes connection configuration details, call level details, and additional attribute details.
- onExitFn()
onExitFn(Object traceContext);
This method is invoked after a public method completes passing the traceContext. Note that this is a synchronous method.
Table 1.48 onExitFn() Parameters Parameter
Data Type
Description
traceContextObject
The trace context details. This includes connection configuration details, call level details, and additional attribute details.
- onBeginRoundTrip()
onBeginRoundTrip(Object traceContext);
Called when a round trip begins. OpenTelemetry will start a new span as a child of the public API span.
Table 1.49 onBeginRoundTrip() Parameters Parameter
Data Type
Description
traceContextObject
The trace context details. This includes connection configuration details, call level details, and additional attribute details.
- onEndRoundTrip()
onEndRoundTrip(Object traceContext);
Called when a round trip ends. OpenTelemetry will end the span. The traceContext object passed in
onBeginRoundTrip()is also passed in this method.Table 1.50 onEndRoundTrip() Parameters Parameter
Data Type
Description
traceContextObject
The trace context details. This includes connection configuration details, call level details, and additional attribute details.
1.9.2. TraceHandler Methods
- oracledb.traceHandler.getTraceInstance()
getTraceInstance();
Returns the user-defined instance implementing the TraceHandlerBase class. Note that this is a synchronous method.
- oracledb.traceHandler.isEnabled()
isEnabled();
Checks if an instance implementing the TraceHandlerBase class is registered and if the abstract methods will be invoked. Note that this is a synchronous method.
- oracledb.traceHandler.setTraceInstance()
setTraceInstance([Object obj]);
Sets the user-defined implementation of the TraceHandlerBase class. Note that this is a synchronous method.
The parameters of the
oracledb.traceHandler.setTraceInstance()method are:Table 1.51 oracledb.traceHandler.setTraceInstance() Parameters Parameter
Data Type
Description
objObject
The singleton object pointing to the traceHandler instance.