Skip to content

Commit 1d298a8

Browse files
committed
Point out that pools should be used for more than one getConnection()
1 parent 8ab8fc5 commit 1d298a8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

doc/api.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7314,12 +7314,15 @@ async function run() {
73147314
let pool;
73157315

73167316
try {
7317+
// Typically a pool is created only when the application starts
73177318
pool = await oracledb.createPool({
73187319
user : "hr",
73197320
password : mypw // mypw contains the hr schema password
73207321
connectString : "localhost/XEPDB1"
73217322
});
73227323

7324+
// Typically there would be multiple pool.getConnection() / connection.close() calls
7325+
// on a pool before the pool is closed.
73237326
let connection;
73247327
try {
73257328
connection = await pool.getConnection();
@@ -7336,10 +7339,13 @@ async function run() {
73367339
}
73377340
}
73387341
}
7342+
73397343
} catch (err) {
73407344
console.error(err.message);
73417345
} finally {
7342-
await pool.close();
7346+
7347+
// At the end of the application, the pool can be closed
7348+
await pool.close(0); // close pool immediately
73437349
}
73447350
}
73457351

0 commit comments

Comments
 (0)