mysql - 在使用 MySQL 的 React Native 项目中,一段时间后我无法调用查询
问题描述
在我的项目中,我访问 MySQL 数据库。我可以通过程序在这个数据库中调用和运行查询。但是,一段时间后,被调用的查询变得功能失调或根本没有被调用。
当我调查我的问题时,我找到了一个解决方案,我需要增加最大连接数。但是,即使我使用它,也没有任何变化。
我尝试了这段代码:SET GLOBAL max_connections = 150;
from this source。
通过 node.js 的连接部分:
const connection = mysql.createPool({
host : '192.168.1.101',
user : 'db_manager',
password : '...',
database : 'venue_recommendation'
});
const app = express();
app.get('/venues', function (req, res) {
let sQuery = "SELECT * FROM mekanlar WHERE mekanlar.mahalle_no=\""+req.query.neig+"\" AND mekanlar.puan >="+req.query.star+" AND mekanlar.fiyat <="+req.query.price+";"
console.log(">>>>>",sQuery)
connection.getConnection(function (err, connection) {
if(err) throw err;
connection.query(sQuery, function (error, results, fields) {
if (error) throw error;
res.send(results);
});
});
});
app.get('/Cuisines', function (req, res) {
let sQuery = "SELECT * FROM mutfaklar;"
console.log(">>>>>",sQuery)
connection.getConnection(function (err, connection) {
if(err) throw err;
connection.query(sQuery, function (error, results, fields) {
if (error) throw error;
res.send(results);
});
});
});
解决方案
推荐阅读
- django - 每当 API 中的 POST 请求时发送邮件
- ruby-on-rails - ActionController::UnknownFormat 在 AnswerController#results
- c - FindHeight(二叉树)方法总是返回 1?
- authentication - 在 asp.netcore 2.1 中使用没有身份的 cookie 身份验证自动重定向
- javascript - 在 select2 V4 中使用数据类型属性值禁用选项
- python - 随机种子在系统之间是否兼容?
- r - dplyr 在循环中使用 complete() 来保留因子级别
- python - 功能列表
- javascript - 未捕获的类型错误:仅在主页上无法读取 null 的属性“addEventListener”
- julia - 使用/导入的 Julia 元编程