This commit is contained in:
omkieit 2024-12-23 13:28:43 +05:30
parent 8d97c43b7b
commit cb52c1f3ad
2 changed files with 11 additions and 2 deletions

View File

@ -7,9 +7,15 @@ const db = mysql.createConnection({
password: "AVNS_tCXJPnroBpPOhL_c7bR",
database: "defaultdb",
port: "25060",
waitForConnections: true,
connectTimeout: 20000, // 20 seconds
ssl: {
rejectUnauthorized: false, // Required for DigitalOcean managed databases
},
});
// const db = mysql.createConnection({
// host: "localhost",
// user: "root",

View File

@ -10,7 +10,10 @@ const pool = mysql.createPool({
waitForConnections: true,
connectionLimit: 10, // Number of connections in the pool
queueLimit: 0, // No limit on queued connection requests
connectTimeout: 20000 // 20 seconds
connectTimeout: 20000, // 20 seconds
ssl: {
rejectUnauthorized: false, // Required for DigitalOcean managed databases
},
});
// Test the pool connection
@ -20,7 +23,7 @@ pool.getConnection()
conn.release(); // Release the connection back to the pool
})
.catch(err => {
console.error("Database connection failed: " + err.stack);
console.error("MYSQL Database connection failed: " + err.stack);
});
export default pool;