# Connection with database error

**URL:** <https://discourse.nodered.org/t/connection-with-database-error/30172>\
**Category:** General\
**Created:** [16 July 2020 06:36 UTC](https://discourse.nodered.org/t/connection-with-database-error/30172 "2020-07-16T06:36:54Z")\
**Posts on this page:** 20\
**Page:** 4

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [17 July 2020 11:12 UTC](https://discourse.nodered.org/t/connection-with-database-error/30172/62 "2020-07-17T11:12:23Z")

</div>

No, where it says \*\*\* Property, change it from `msg.payload` to `msg.topic`

---

<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:** [17 July 2020 11:12 UTC](https://discourse.nodered.org/t/connection-with-database-error/30172/63 "2020-07-17T11:12:46Z")

</div>

No. Change the `Property` field at the top to say `topic` rather than `payload`, and leave the Template as you had it before:

```auto
SELECT rfidno FROM rfid1 
WHERE rfidno='{{payload}}';

```

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [17 July 2020 11:14 UTC](https://discourse.nodered.org/t/connection-with-database-error/30172/64 "2020-07-17T11:14:02Z")

</div>

> [@zenofmud](#):
>
> ```auto
> SELECT rfidno FROM rfid1 
> WHERE rfidno='{{payload}}';
> 
> ```

ok Done ,Now Tell

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [17 July 2020 11:15 UTC](https://discourse.nodered.org/t/connection-with-database-error/30172/65 "2020-07-17T11:15:05Z")

</div>

Great, so now run your flow with a good RFID and a bad RFID and show the results.

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [17 July 2020 11:20 UTC](https://discourse.nodered.org/t/connection-with-database-error/30172/66 "2020-07-17T11:20:10Z")

</div>

What to write in switch node and change node

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [17 July 2020 11:22 UTC](https://discourse.nodered.org/t/connection-with-database-error/30172/67 "2020-07-17T11:22:10Z")

</div>

![a](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/d/6d7e8b9c421248d91b1d4473c5590196c9ccd660.png)  
like this i have to write .Sorry For troubling ,but as i am new I dont have idea.

---

<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:** [17 July 2020 11:26 UTC](https://discourse.nodered.org/t/connection-with-database-error/30172/68 "2020-07-17T11:26:35Z")

</div>

You may have missed where I suggested:

> I then recommend you add a `Debug` node after the mysql node so you can see exactly what it is returning. That will help you/us identify how to configure the Switch node to test if the query found a match or not.

Until we can see what the mysql node is returning for both a 'good' result and a 'bad' result, we can't tell you how to configure the Switch node.

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [17 July 2020 11:28 UTC](https://discourse.nodered.org/t/connection-with-database-error/30172/69 "2020-07-17T11:28:31Z")

</div>

![d](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/5/e5bc4bbb0b25f2b6e37652a0193270ec38939e4d.png) ![dd](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/9/0951d15a9b8a96c3ec479c510a7b9d16cdb60bbb.png) sure check this ones

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [17 July 2020 11:29 UTC](https://discourse.nodered.org/t/connection-with-database-error/30172/70 "2020-07-17T11:29:46Z")

</div>

Now run with a bad RFID and show the results

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [17 July 2020 11:31 UTC](https://discourse.nodered.org/t/connection-with-database-error/30172/71 "2020-07-17T11:31:44Z")

</div>

![g](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/b/1b91e5ec5900aa3c5d489291d065dd4e0ff06a9c.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [17 July 2020 11:34 UTC](https://discourse.nodered.org/t/connection-with-database-error/30172/72 "2020-07-17T11:34:47Z")

</div>

Now add this `change` node after the `mysql` node and it will output one side of the output for a good RFID and the other for a bad RFID.

```auto
[{"id":"513c017d.be004","type":"switch","z":"4fe1dfa2.29df78","name":"","property":"payload","propertyType":"msg","rules":[{"t":"empty"},{"t":"nempty"}],"checkall":"false","repair":false,"outputs":2,"x":610,"y":240,"wires":[["50ab302f.1c6958"],["2c15b7c7.468878"]]}]

```

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [17 July 2020 11:43 UTC](https://discourse.nodered.org/t/connection-with-database-error/30172/73 "2020-07-17T11:43:23Z")

</div>

![gh](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/2/12398635626c91d3e067842328352d07236bf754.png)  
like this.now what to write in change node

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [17 July 2020 11:50 UTC](https://discourse.nodered.org/t/connection-with-database-error/30172/74 "2020-07-17T11:50:41Z")

</div>

now what next .please help

---

<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:** [17 July 2020 11:53 UTC](https://discourse.nodered.org/t/connection-with-database-error/30172/75 "2020-07-17T11:53:57Z")

</div>

Have you imported the Switch node that @zenofmud gave you?

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [17 July 2020 11:54 UTC](https://discourse.nodered.org/t/connection-with-database-error/30172/76 "2020-07-17T11:54:52Z")

</div>

Switch node i have drag and drop in my node red

---

<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:** [17 July 2020 11:57 UTC](https://discourse.nodered.org/t/connection-with-database-error/30172/77 "2020-07-17T11:57:30Z")

</div>

No. He gave you a piece of JSON in his last reply. Copy that JSON, then import it into the editor. That will give you a switch node that is configured to separate out the good and bad messages.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [17 July 2020 11:58 UTC](https://discourse.nodered.org/t/connection-with-database-error/30172/78 "2020-07-17T11:58:10Z")

</div>

Did you import the change node I provided in my last post? If not, please import it and remove the change node you created.

---

<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:** [17 July 2020 11:58 UTC](https://discourse.nodered.org/t/connection-with-database-error/30172/79 "2020-07-17T11:58:39Z")

</div>

@zenofmud to avoid confusion, it's a Switch node you have provided, not a Change node.

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [17 July 2020 12:00 UTC](https://discourse.nodered.org/t/connection-with-database-error/30172/80 "2020-07-17T12:00:24Z")

</div>

ya i have done it shows a switch node poped up

---

<div class="post-metadata">

**Author:** ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)\
**Post date:** [17 July 2020 12:01 UTC](https://discourse.nodered.org/t/connection-with-database-error/30172/81 "2020-07-17T12:01:37Z")

</div>

i changed the "switch" to "change" in json object

[Previous page](https://discourse.nodered.org/t/connection-with-database-error/30172.md?page=3)

[Next page](https://discourse.nodered.org/t/connection-with-database-error/30172.md?page=5)
