title: nodejs- TypeError: connection.connect is not a function
body: <p>I have an app developed using ExpressJS (Express 4) framework. I am planning to use connection pooling instead of single connection, heard it allows us to reuse existing database connections instead of opening a new connection for every request to the Node application.</p>
  
  <p>So in the existing code, I made a change.
  Replaced <code>mysql.createConnection</code> with <code>mysql.createPool</code> in the following code
  Note: This is just a portion of the app where the database connection is getting established.</p>
  
  <pre><code>  var mysql = require('mysql'),
      connection = mysql.createPool({
        host: 'localhost',
        user: 'root',
        password: '',
        database: 'test_db',
        port: 3306
      });
    connection.connect(function (err) {
      if (err) {
        console.log(err);
      }
    });
  </code></pre>
  
  <p>But when I run the app, I got the following error.</p>
  
  <pre><code>TypeError: connection.connect is not a function
  </code></pre>
  
  <p>Can anyone tell me how to resolve this error? Thanks!</p>
  
  <p>Package.json file</p>
  
  <pre><code>{
    "name": "testapp",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
      "test": "hola"
    },
    "author": "user",
    "license": "ISC",
    "dependencies": {
      "body-parser": "^1.18.2",
      "cake-hash": "0.0.6",
      "compression": "^1.7.1",
      "cors": "^2.8.4",
      "express": "^4.16.2",
      "https": "^1.0.0",
      "moment": "^2.19.2",
      "morgan": "^1.9.0",
      "mysql": "^2.15.0"
    }
  }
  </code></pre>