# Error: Pool is not a constructor

**URL:** <https://discourse.nodered.org/t/error-pool-is-not-a-constructor/19163>\
**Category:** General\
**Created:** [14 December 2019 21:23 UTC](https://discourse.nodered.org/t/error-pool-is-not-a-constructor/19163 "2019-12-14T21:23:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nrnoob](https://avatars.discourse-cdn.com/v4/letter/n/77aa72/32.png) [@nrnoob](https://discourse.nodered.org/u/nrnoob)\
**Post date:** [14 December 2019 21:23 UTC](https://discourse.nodered.org/t/error-pool-is-not-a-constructor/19163/1 "2019-12-14T21:23:28Z")

</div>

I am trying to use node-red-contrib-odbc which requires the node-odbc node.  
I am getting "TypeError: Pool is not a constructor" in this line: this.pool = new Pool();  
I am pasting the contents from odbc.js for more context.

module.exports = function(RED) {

```
"use strict";

var mustache = require("mustache");

var Pool = require("odbc").Pool;

function connection(config) {

    RED.nodes.createNode(this, config);

    this.cn = "";

    if (config.driver!=""){

        this.cn = this.cn + "DRIVER="+config.driver + ";"

    }

    if (config.server!=""){

        this.cn = this.cn + "SERVER="+config.server + ";"

    }

    if (this.credentials.username!=""){

        this.cn = this.cn + "USER="+ this.credentials.username + ";"

    }

    if (this.credentials.password != ""){

        this.cn = this.cn + "PASSWORD="+ this.credentials.password + ";"

    }

    this.cn = this.cn + config.other;

    this.pool = new Pool();

    var node = this;

}

```

What do I need to change here to make it work?  
Sorry if this appears too trivial a question. Stating the obvious - total Node-red noob here.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [15 December 2019 09:09 UTC](https://discourse.nodered.org/t/error-pool-is-not-a-constructor/19163/2 "2019-12-15T09:09:29Z")

</div>

What database are you trying to connect to ?

The odbc node is 4+ years old, it is likely that it won't function properly.

---

<div class="post-metadata">

**Author:** ![nrnoob](https://avatars.discourse-cdn.com/v4/letter/n/77aa72/32.png) [@nrnoob](https://discourse.nodered.org/u/nrnoob)\
**Post date:** [15 December 2019 10:17 UTC](https://discourse.nodered.org/t/error-pool-is-not-a-constructor/19163/3 "2019-12-15T10:17:09Z")

</div>

Its an industrial automation software which has to be accessed over ODBC or OLEDB.  
OLEDB needs access via COM, hence I wanted to avoid using in Node-Red as it would bring more complications.  
Node-red is a great tool, but node maintenance is becoming an issue it seems.

I just felt that there was a minor detail in the ODBC node which could fix this issue. E.g. the Pool class needs a connection string I think, which is not visible in the line \> this.pool = new Pool();

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [15 December 2019 10:22 UTC](https://discourse.nodered.org/t/error-pool-is-not-a-constructor/19163/4 "2019-12-15T10:22:21Z")

</div>

> maintenance is becoming an issue

Insert any software.

---

<div class="post-metadata">

**Author:** ![molesworth](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/molesworth/32/11748_2.png) [@molesworth](https://discourse.nodered.org/u/molesworth)\
**Post date:** [15 December 2019 15:58 UTC](https://discourse.nodered.org/t/error-pool-is-not-a-constructor/19163/5 "2019-12-15T15:58:04Z")

</div>

I'm not an expert on the nuances of Node.js, but it could be that your "require" needs to use a different name. You have two uses of "Pool" :

> [@](#):
>
> var Pool = require("odbc").Pool;

versus :

> [@](#):
>
> this.pool = new Pool();

You could either use a different var name, or possibly you need "new Pool.Pool()". (As I said, I'm no expert, but in other languages this would likely be flagged as an error.)

---

<div class="post-metadata">

**Author:** ![nrnoob](https://avatars.discourse-cdn.com/v4/letter/n/77aa72/32.png) [@nrnoob](https://discourse.nodered.org/u/nrnoob)\
**Post date:** [16 December 2019 18:21 UTC](https://discourse.nodered.org/t/error-pool-is-not-a-constructor/19163/6 "2019-12-16T18:21:15Z")

</div>

I tried that - same error. If I just update the .js file, is it enough to update the node, or do I need to 'compile' or do something else?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [16 December 2019 20:39 UTC](https://discourse.nodered.org/t/error-pool-is-not-a-constructor/19163/7 "2019-12-16T20:39:08Z")

</div>

Hi @nrnoob,

the problem comes from the fact its package.json lists its dependency on the odbc module as this:

```auto
    "odbc": ">=0.6.11",

```

This means it will accepy _anything_ newer than (or equal to) version 0.6.11. The `odbc` module is currently on version 2.2.2 - which means its had two major breaking version releases since the version the node was written for.

A quick fix would be to change the package.json file to install a version of `odbc` that is more likely to be compatible. For example, change `">=0.6.11"` to `"<1.0"`. Then run `npm install` from that directory.

Otherwise, it's a case of reading up on the `odbc` module and learning what changes it made in its `2.x` branch and then updating the node's code to match.

> **[odbc](https://www.npmjs.com/package/odbc#important-changes-in-20)**
>
> unixodbc bindings for node

---

<div class="post-metadata">

**Author:** ![nrnoob](https://avatars.discourse-cdn.com/v4/letter/n/77aa72/32.png) [@nrnoob](https://discourse.nodered.org/u/nrnoob)\
**Post date:** [18 December 2019 08:14 UTC](https://discourse.nodered.org/t/error-pool-is-not-a-constructor/19163/8 "2019-12-18T08:14:07Z")

</div>

Thanks. I will try out your suggestions.
