首页 > 解决方案 > 在使用 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);
  });
  });
});

标签: mysqlsqlnode.jsreact-nativedatabase-connection

解决方案


推荐阅读