When nodejs connected to mysql database, there was a problem that the data was received normally at the first connection, but when the page redirection was updated, it was wrong, and the node service would be disconnected. As shown in figure
error code is as follows:
after searching online, it was found that res.send() contains res.end() method. After calling res.end() once, the data returned normally, but res.end() was executed at the same time
The solution
Will res. The send (); Just comment it out.
, but then it reports an Error, as shown in figure
Error: Cannot enqueue Quit after invoking Quit.
I use the mysql module, because I call connection.end() frequently; This error occurred, so the final code is as follows
//Search School List
router.get('/school', function(req, res, next) {
connection.query("select * from school",function (err, result) {
if(err){
// res.send(err.message);
res.json({
status:"1",
msg:err.message
});
return;
}else{
// res.send(result);
res.json({
status:"0",
msg:result
});
}
});
// connection.end();
// res.send('respond with a resource');
});
Read More:
- [Solved] public key is not available client side (option serverRsaPublicKeyFile not set)
- [Solved] there are special symbols in the initial password for installing MySQL in Hadoop, and an error is reported
- MYSQL Slave is not configured or failed to initialize properly. You must at least set –server-id
- [Solved] mysqli::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers in
- After installing mysql5.7 on centos7, an error 1045 (28000) is reported: access denied for user ‘root’ @’localhost ‘(using PAS)
- Python calls the MySQLdb library, and an error “Library not loaded: libmysqlclient.18.dylib” is reported
- Navicat connected to Mysql error: Client does not support authentication protocol requested by server;
- [Solved] MySQL Error: Client does not support authentication protocol requested by server
- [Solved] Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as
- MYSQL8 Startup Error: mysqld_safe error: log-error set to ‘/var/log/mariadb/mariadb.log‘
- [ERROR] [FATAL] InnoDB: Table flags are 0 in the data dictionary but the flags in file ./ibdata
- [Solved] Manifest merger failed: Apps targeting Android 12 and higher are required to specify an explicit va
- How to Fix MySQL ERROR 1130 (HY000): Host ‘XXXX’ is not allowed to connect to this MySQL server
- [Solved] Running in 64 bit mode with the 32 bit Oracle client installed
- MYSQL Index Key Length 1071 – Specified key was too long; max key length is 3072 bytes
- [Solved] Error: ER_HOST_NOT_PRIVILEGED: Host ‘x.x.x.x‘ is not allowed to connect to this MySQL server
- MySQL Error: [ERROR] [FATAL] InnoDB: Table flags are 0 in the data dictionary but the flags in file
- Remote connection to MySQL database error: is not allowed to connect to this MYSQL server solution
- linux mysql ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
- MYSQL Safe Upgraded Error: You are using safe update mode and you tried to update