From 42d8b76323101f4f94214a1d0ec3a7ffaf650c41 Mon Sep 17 00:00:00 2001 From: Sanket Gandhi <35518677+sanketgandhi876@users.noreply.github.com> Date: Mon, 3 Jun 2024 15:52:17 +0530 Subject: [PATCH 1/2] Added close connections Close connections were missing so I have added it in quickstart. --- website/docs/index.mdx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/website/docs/index.mdx b/website/docs/index.mdx index 90cda8cd0b..22cfc204a8 100644 --- a/website/docs/index.mdx +++ b/website/docs/index.mdx @@ -105,6 +105,9 @@ try { } catch (err) { console.log(err); } + +// Close the connection +await connection.end(); ``` @@ -138,6 +141,9 @@ connection.query( console.log(results); } ); + +// Close the connection +connection.end(); ``` @@ -179,6 +185,8 @@ try { console.log(fields); // fields contains extra meta data about results, if available } catch (err) { console.log(err); +} finally { + connection.end() } ``` @@ -204,6 +212,9 @@ connection.execute( console.log(fields); // fields contains extra meta data about results, if available } ); + +// Close the connection +connection.end(); ``` From eecc45e61b0ced91687be8c09539c38e8d8602f2 Mon Sep 17 00:00:00 2001 From: Sanket Gandhi <35518677+sanketgandhi876@users.noreply.github.com> Date: Mon, 3 Jun 2024 19:16:45 +0530 Subject: [PATCH 2/2] Issue fixed --- website/docs/index.mdx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/website/docs/index.mdx b/website/docs/index.mdx index 22cfc204a8..f9d69207e1 100644 --- a/website/docs/index.mdx +++ b/website/docs/index.mdx @@ -167,9 +167,11 @@ MySQL2 provides `execute` helper which will prepare and query the statement. You ```js import mysql from 'mysql2/promise'; +let connection; + try { // create the connection to database - const connection = await mysql.createConnection({ + connection = await mysql.createConnection({ host: 'localhost', user: 'root', database: 'test',