I am using node js for web service I use
connection.query('select * from users where email=?',[email],
connection.query('insert into message(??,time,type,user_id) values(?,?,?,?)',[messagecolumns,dbValues,time,type,user_id],
connection.query('select u.firstname,u.lastname,u.img_path,m.* from users u, message m where u.id=m.user_id and m.id=?',[message_inserted.insertId],
connection.query('select count(id) as message_count from message where appointment_request_id=?',[appointment_request_id],
connection.query('update appointment_request set message_count=? where appointment_request_id=?',[total_message.message_count,appointment_request_id],
A pool has a limited number of connections (Default is 10).
getConnection then one of those connections is removed from pool and is passed to you so that you can use it. You will call
connection.release() after you are finished working with the connection. As soon as you called
connection.release() the connection is passed back to the pool and is free to be used by other parts of your code. As of that it is not valid to work with this connection after you have called release on it, because it might be closed or used by another part of your code that requested a connection with
getConnection (in most of the cases it might still work, but it could unexpectedly fail).
In your code you call
connection.release(); at the beginning of you callback so the usage of
connection after that
release is not valid.
You you must not call
connection.release() multiple times on the same connection.