@@ -360,9 +360,9 @@ For installation information, see the [Node-oracledb Installation Instructions][
360
360
- 14.1.3 [ Optional Oracle Client Configuration] ( #oraaccess )
361
361
- 14.2 [ Connection Strings] ( #connectionstrings )
362
362
- 14.2.1 [ Easy Connect Syntax for Connection Strings] ( #easyconnect )
363
- - 14.2.2 [ Net Service Names for Connection Strings] ( #tnsnames )
364
- - 14.2.3 [ Embedded Connection Strings] ( #embedtns )
365
- - 14.2.4 [ JDBC and Node-oracledb Connection Strings Compared ] ( #notjdbc )
363
+ - 14.2.2 [ Embedded Connect Descriptor Strings] ( #embedtns )
364
+ - 14.2.3 [ Net Service Names for Connection Strings] ( #tnsnames )
365
+ - 14.2.4 [ JDBC and Oracle SQL Developer Connection Strings] ( #notjdbc )
366
366
- 14.3 [ Connections and Number of Threads] ( #numberofthreads )
367
367
- 14.4 [ Connection Pooling] ( #connpooling )
368
368
- 14.4.1 [ Connection Pool Sizing] ( #conpoolsizing )
@@ -6849,64 +6849,86 @@ The `oraaccess.xml` file has other uses including:
6849
6849
6850
6850
### <a name =" connectionstrings " ></a > 14.2 Connection Strings
6851
6851
6852
- The ` connectString ` parameter for
6853
- [ ` oracledb.getConnection() ` ] ( #getconnectiondb ) and
6854
- [ ` oracledb.createPool() ` ] ( #createpool ) can be an
6855
- [ Easy Connect] ( #easyconnect ) string, or a Net Service Name from a
6856
- local [ ` tnsnames.ora ` ] ( #tnsnames ) file or external naming service, or
6857
- it can be the SID of a local Oracle database instance.
6852
+ The ` connectString ` property for [ ` oracledb.getConnection() ` ] ( #getconnectiondb )
6853
+ and [ ` oracledb.createPool() ` ] ( #createpool ) can be one of:
6858
6854
6859
- The ` connectionString ` property is an alias for ` connectString ` .
6860
- Use only one of the properties.
6855
+ - An [ Easy Connect] ( #easyconnect ) string
6856
+ - A [ Connect Descriptor] ( #embedtns ) string
6857
+ - A [ Net Service Name] ( #tnsnames ) from a local [ ` tnsnames.ora ` ] ( #tnsnames ) file or external naming service
6858
+ - The SID of a local Oracle database instance
6861
6859
6862
6860
If a connect string is not specified, the empty string "" is used
6863
6861
which indicates to connect to the local, default database.
6864
6862
6863
+ The ` connectionString ` property is an alias for ` connectString ` .
6864
+ Use only one of the properties.
6865
+
6865
6866
#### <a name =" easyconnect " ></a > 14.2.1 Easy Connect Syntax for Connection Strings
6866
6867
6867
- An Easy Connect string is often the simplest to use. With Oracle Database 12 or later
6868
- the syntax is:
6868
+ An Easy Connect string is often the simplest to use. For example, to connect to
6869
+ the Oracle Database service `` orclpdb1 `` that is running on the host
6870
+ `` mydbmachine.example.com `` with the default Oracle Database port 1521, use:
6869
6871
6870
6872
```
6871
- [//]host_name[:port][/service_name][:server_type][/instance_name]
6872
- ```
6873
+ const oracledb = require('oracledb');
6873
6874
6874
- Note that old-school connection SIDs are not supported: only service names can be used.
6875
+ const connection = await oracledb.getConnection(
6876
+ {
6877
+ user : "hr",
6878
+ password : mypw, // mypw contains the hr schema password
6879
+ connectString : "mydbmachine.example.com/orclpdb1"
6880
+ }
6881
+ );
6882
+ ```
6875
6883
6876
- For example, use * "localhost/XEPDB1"* to connect to the database * XE* on the local machine:
6884
+ If the database is using a non-default port, for example 1984, the port must be
6885
+ given:
6877
6886
6878
- ``` javascript
6887
+ ```
6879
6888
const oracledb = require('oracledb');
6880
6889
6881
6890
const connection = await oracledb.getConnection(
6882
6891
{
6883
6892
user : "hr",
6884
6893
password : mypw, // mypw contains the hr schema password
6885
- connectString : " localhost/XEPDB1 "
6894
+ connectString : "mydbmachine.example.com:1984/orclpdb1 "
6886
6895
}
6887
6896
);
6888
6897
```
6889
6898
6890
- For more information on Easy Connect strings see [ Understanding the
6891
- Easy Connect Naming Method] [ 17 ] in the Oracle documentation.
6899
+ The Easy Connect syntax supports Oracle Database service names. It cannot be
6900
+ used with the older System Identifiers (SID).
6901
+
6902
+ The Easy Connect syntax has been extended in recent versions of Oracle Database
6903
+ client since its introduction in 10g. Check the Easy Connect Naming method in
6904
+ [ Oracle Net Service Administrator's Guide] [ 17 ] for the syntax to use in your
6905
+ version of the Oracle Client libraries.
6892
6906
6893
- #### <a name =" tnsnames " ></a > 14.2.2 Net Service Names for Connection Strings
6907
+ If you are using Oracle Client 19c, the latest [ Easy Connect Plus] [ 151 ] syntax
6908
+ allows the use of multiple hosts or ports, along with optional entries for the
6909
+ wallet location, the distinguished name of the database server, and even lets
6910
+ some network configuration options be set. This means that a
6911
+ [ ` sqlnet.ora ` ] ( #tnsadmin ) file is not needed for some common connection
6912
+ scenarios.
6894
6913
6895
- A Net Service Name, such as ` sales ` in the example below, can be used
6896
- to connect:
6914
+ #### <a name =" embedtns " ></a > 14.2.2 Embedded Connect Descriptor Strings
6915
+
6916
+ Full Connect Descriptor strings can be embedded in applications:
6897
6917
6898
6918
``` javascript
6899
6919
const connection = await oracledb .getConnection (
6900
6920
{
6901
6921
user : " hr" ,
6902
6922
password : mypw, // mypw contains the hr schema password
6903
- connectString : " sales "
6923
+ connectString : " (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=mymachine.example.com)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl))) "
6904
6924
}
6905
6925
);
6906
6926
```
6907
6927
6908
- This could be defined in a directory server, or in a local
6909
- ` tnsnames.ora ` file, for example:
6928
+ #### <a name =" tnsnames " ></a > 14.2.3 Net Service Names for Connection Strings
6929
+
6930
+ Connect Descriptor strings are commmonly stored in [ ` tnsnames.ora ` ] ( #tnsadmin )
6931
+ files and associated with a Net Service Name, for example:
6910
6932
6911
6933
```
6912
6934
sales =
@@ -6919,6 +6941,20 @@ sales =
6919
6941
)
6920
6942
```
6921
6943
6944
+ Net Service Names may also be defined in a directory server.
6945
+
6946
+ Given a Net Service Name, node-oracledb can connect like:
6947
+
6948
+ ``` javascript
6949
+ const connection = await oracledb .getConnection (
6950
+ {
6951
+ user : " hr" ,
6952
+ password : mypw, // mypw contains the hr schema password
6953
+ connectString : " sales"
6954
+ }
6955
+ );
6956
+ ```
6957
+
6922
6958
Some older databases may use a 'SID' instead of a 'Service Name'. A
6923
6959
connection string for these databases could look like:
6924
6960
@@ -6933,60 +6969,71 @@ sales =
6933
6969
)
6934
6970
```
6935
6971
6936
- See [ Optional Oracle Net Configuration] ( #tnsadmin ) for where
6937
- ` tnsnames.ora ` files can be located.
6972
+ See [ Optional Oracle Net Configuration] ( #tnsadmin ) for where ` tnsnames.ora `
6973
+ files can be located.
6938
6974
6939
- For more information on ` tnsnames.ora ` files, see the [ Oracle Net
6975
+ For general information on ` tnsnames.ora ` files, see the [ Oracle Net
6940
6976
documentation on ` tnsnames.ora ` ] [ 18 ] .
6941
6977
6942
- #### <a name =" embedtns " ></a > 14.2.3 Embedded Connection Strings
6978
+ #### <a name =" notjdbc " ></a > 14.2.4 JDBC and Oracle SQL Developer Connection Strings
6979
+
6980
+ The node-oracledb connection string syntax is different to Java JDBC and the
6981
+ common Oracle SQL Developer syntax. If these JDBC connection strings reference
6982
+ a service name like:
6943
6983
6944
- Full connection strings can be embedded in applications:
6984
+ jdbc:oracle:thin:@hostname:port/service_name
6985
+
6986
+ for example:
6987
+
6988
+ ```
6989
+ jdbc:oracle:thin:@mydbmachine.example.com:1521/orclpdb1
6990
+ ```
6991
+
6992
+ then use Oracle's Easy Connect syntax in node-oracledb:
6945
6993
6946
6994
``` javascript
6947
6995
const connection = await oracledb .getConnection (
6948
6996
{
6949
6997
user : " hr" ,
6950
6998
password : mypw, // mypw contains the hr schema password
6951
- connectString : " (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=mymachine .example.com)(PORT= 1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl))) "
6999
+ connectString : " mydbmachine .example.com: 1521/orclpdb1 "
6952
7000
}
6953
7001
);
6954
7002
```
6955
7003
6956
- #### <a name =" notjdbc " ></a > 14.2.4 JDBC and Node-oracledb Connection Strings Compared
7004
+ Alternatively, if a JDBC connection string uses an old-style
7005
+ Oracle system identifier [ SID] [ 19 ] , and there is no service name available:
6957
7006
6958
- Developers familiar with Java connection strings that reference a
6959
- service name like:
7007
+ ```
7008
+ jdbc:oracle:thin:@hostname:port:sid
7009
+ ```
7010
+
7011
+ for example:
6960
7012
6961
7013
```
6962
- jdbc:oracle:thin:@hostname:port/service_name
7014
+ jdbc:oracle:thin:@mydbmachine.example.com:1521:orcl
6963
7015
```
6964
7016
6965
- can use Oracle's Easy Connect syntax in node-oracledb :
7017
+ then either [ embed the Connect Descriptor ] ( #embedtns ) :
6966
7018
6967
7019
``` javascript
6968
7020
const connection = await oracledb .getConnection (
6969
7021
{
6970
7022
user : " hr" ,
6971
7023
password : mypw, // mypw contains the hr schema password
6972
- connectString : " hostname:port/service_name "
7024
+ connectString : " (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=mymachine.example.com)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SID=ORCL))) "
6973
7025
}
6974
7026
);
6975
7027
```
6976
7028
6977
- Alternatively, if a JDBC connection string uses an old-style
6978
- Oracle system identifier [ SID] [ 19 ] , and there is no service name available:
7029
+ or create a [ Net Service Name] ( #tnsnames ) :
6979
7030
6980
7031
```
6981
- jdbc:oracle:thin:@hostname:port:sid
6982
- ```
7032
+ # tnsnames.ora
6983
7033
6984
- then consider creating a [ ` tnsnames.ora ` ] ( #tnsnames ) entry, for example:
6985
-
6986
- ```
6987
7034
finance =
6988
7035
(DESCRIPTION =
6989
- (ADDRESS = (PROTOCOL = TCP)(HOST = hostname )(PORT = 1521))
7036
+ (ADDRESS = (PROTOCOL = TCP)(HOST = mydbmachine.example.com )(PORT = 1521))
6990
7037
(CONNECT_DATA =
6991
7038
(SID = ORCL)
6992
7039
)
@@ -7005,8 +7052,6 @@ const connection = await oracledb.getConnection(
7005
7052
);
7006
7053
```
7007
7054
7008
- Alternatively the connection string can be [ embedded] ( #embedtns ) in the application.
7009
-
7010
7055
### <a name =" numberofthreads " ></a > 14.3 Connections and Number of Threads
7011
7056
7012
7057
If you open more than four connections, such as via
@@ -7269,7 +7314,7 @@ connections.
7269
7314
7270
7315
Pools are added to the cache by using a
7271
7316
[ ` poolAlias ` ] ( #createpoolpoolattrspoolalias ) property in the
7272
- [ ` poolAttrs ` ] ( #createpoolpoolattrs ) object::
7317
+ [ ` poolAttrs ` ] ( #createpoolpoolattrs ) object:
7273
7318
7274
7319
``` javascript
7275
7320
async function init () {
@@ -13127,7 +13172,7 @@ Some QBE examples are:
13127
13172
### <a name="sodatextsearches"></a> 29.5 SODA Text Searches
13128
13173
13129
13174
To perform text searches through documents, a [JSON search index][149]
13130
- must be defined. For example::
13175
+ must be defined. For example:
13131
13176
13132
13177
` ` ` javascript
13133
13178
await collection .createIndex ({ name : " mySearchIdx" );
@@ -14027,3 +14072,4 @@ When upgrading from node-oracledb version 3.1 to version 4.0:
14027
14072
[148]: https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-C4C426FC-FD23-4B2E-8367-FA5F83F3F23A
14028
14073
[149]: https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-4848E6A0-58A7-44FD-8D6D-A033D0CCF9CB
14029
14074
[150]: https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-7E9034D5-0D33-43A1-9012-918350FE148C
14075
+ [151]: https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-8C85D289-6AF3-41BC-848B-BF39D32648BA
0 commit comments