2

I would like to know if I am to use createConnection instead of using createPool, does it mean that the createConnection pool will be automatically created and closed when done with the query?

Many thanks in advance.

Nat
  • 679
  • 1
  • 9
  • 24

2 Answers2

1

What is the different createConnection vs createPool of MySQL NodeJS and in fact, using createPool the right way to go. Please refer here for the answer.

https://codeforgeek.com/nodejs-mysql-tutorial/

Nat
  • 679
  • 1
  • 9
  • 24
0

Connection Pooling (createPool) is a mechanism to maintain a cache of database connection so that the connection can be reused after releasing it. So connections get stored, and do not need to get closed.

While using a connection (createConnection), you only have one connection and it lasts until you close it.

djadweb
  • 29
  • 2