diff --git a/app.js b/app.js
index fae6bb3cf07a3cc9762945b24fb138eea3043306..dcc83790bea50afa48c5ec7b64d64d80c4a8690b 100644
--- a/app.js
+++ b/app.js
@@ -5,7 +5,7 @@ const app = express();
 const port = 3000;
 
 // การตั้งค่าการเชื่อมต่อฐานข้อมูล MySQL (ใช้ pool)
-const db = mysql.createConnection({
+const db = mysql.createPool({
   host: process.env.DB_HOST,
   port: process.env.DB_PORT,
   user: process.env.DB_USER,
@@ -17,14 +17,14 @@ const db = mysql.createConnection({
 });
 
 // Test the database connection to ensure everything is set up correctly
-db.connect(err => {
+db.getConnection((err, connection) => {
   if (err) throw err;
   console.log("Connected to the database.");
+  connection.release(); // Release the connection back to the pool
 });
 
 module.exports = { db };
 
-
 // การตั้งค่า Express session
 app.use(session({
     secret: 'your_secret_key',
@@ -55,8 +55,8 @@ app.get('/', (req, res) => {
 app.use('/auth', require('./routes/auth'));
 app.use('/admin', require('./routes/admin'));
 app.use('/customer', require('./routes/customer'));
-  
+
 // Starting the server
 app.listen(port, () => {
     console.log(`Server is running on http://localhost:${port}`);
-});
\ No newline at end of file
+});