Devasish
Devasish

Reputation: 1957

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...

Upvotes: 2

Views: 2177

Answers (1)

mkinawy
mkinawy

Reputation: 375

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.

Upvotes: 3

Related Questions