@WrRan
2016-11-17T08:55:02.000000Z
字数 3351
阅读 1352
node-oracledb
A connection Pool object is created by calling the
createPool()
method of the Oracledb object.
The Pool object obtains connections to the Oracle database using the
getConnection()
method to "check them out" from the pool. Internally
OCI Session Pooling
is used.
After the application finishes using a connection pool, it should
release all connections and terminate the connection pool by calling
the close()
method on the Pool object.
See Connection Pooling for more information.
The Pool object properties may be read to determine the current
values.
readonly Number connectionsInUse
The number of currently active connections in the connection pool
i.e. the number of connections currently checked-out using
getConnection()
.
readonly Number connectionsOpen
The number of currently open connections in the underlying connection
pool.
readonly Number poolAlias
The alias of this pool in the connection pool cache. An alias cannot be changed once the pool has been created.
readonly Number poolIncrement
The number of connections that are opened whenever a connection
request exceeds the number of currently open connections.
readonly Number poolMax
The maximum number of connections that can be open in the connection
pool.
readonly Number poolMin
The minimum number of connections a connection pool maintains, even
when there is no activity to the target database.
readonly Number poolTimeout
The time (in seconds) after which the pool terminates idle connections
(unused in the pool). The number of connections does not drop below
poolMin.
readonly Boolean queueRequests
Determines whether requests for connections from the pool are queued
when the number of connections "checked out" from the pool has reached
the maximum number specified by poolMax
.
readonly Number queueTimeout
The time (in milliseconds) that a connection request should wait in
the queue before the request is terminated.
readonly Number stmtCacheSize
The number of statements to be cached in the
statement cache of each connection.
Callback:
close(function(Error error){});
Promise:
promise = close();
This call terminates the connection pool.
Any open connections should be released with connection.close()
before pool.close()
is called.
If the pool is in the connection pool cache it will be removed from the cache.
function(Error error)
The parameters of the callback function are:
Callback function parameter | Description |
---|---|
Error error | If close() succeeds, error is NULL. If an error occurs, then error contains the error message. |
Callback:
getConnection(function(Error error, Connection conn){});
Promise:
promise = getConnection();
This method obtains a connection from the connection pool.
If a previously opened connection is available in the pool, that
connection is returned. If all connections in the pool are in use, a
new connection is created and returned to the caller, as long as the
number of connections does not exceed the specified maximum for the
pool. If the pool is at its maximum limit, the getConnection()
call
results in an error, such as ORA-24418: Cannot open further sessions.
See Connection Handling for more information on
connections.
function(Error error, Connection conn)
The parameters of the callback function are:
Callback function parameter | Description |
---|---|
Error error | If getConnection() succeeds, error is NULL. If an error occurs, then error contains the error message. |
Connection connection | The newly created connection. If getConnection() fails, connection will be NULL. See Connection class for more details. |
An alias for pool.close().