简体   繁体   中英

Is it necessary to close database connection in node js with SQL Server?

I am using npm-mssql with nodejs. Can anybody please confirm me if I need to close the database connection manually or is it automatically closed?

I have got some info here but not clear to me. Please help...

It would be closed automatically when the garbage collector works!

Though it's a good practice to close any db connection manually after you are done with it, db connection is a heavy resource so closing it to dispose the occupied resources is always a good idea and best practice.

Not only for db connections, but that should be the case for any heavy resource process, like any other I/O operation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM