mysql - 使用mysql应用程序在nodejs中收到无效字段长度错误

标签 mysql node.js express

从我的 SQL 数据库获取记录(大约 50 行)时出现以下错误。我的应用程序是在nodejs和express中开发的。 enter image description here

var common = require(__base + 'routes/common.js');
var dbhelper = require(__base + 'routes/dbhelper.js');

exports.GetStates = function (callback) {
    dbhelper.pool.getConnection(function (err, connection) {
        // Use the connection
        connection.query('CALL GetStates()',
            function (err, res) {
                connection.release();
                if (err) {
                    common.ActionOutput.Status = common.ActionStatus.Error;
                    common.ActionOutput.Message = 'System Error: ' + err.message;
                } else {
                    common.ActionOutput.Status = common.ActionStatus.Success;
                    common.ActionOutput.Result = res[0][0];
                }
                return callback(JSON.stringify(common.ActionOutput));
            });
    });
};

dbhelper.js is

// Database connection
var mysql = require('mysql');

var pool = mysql.createPool({
    connectionLimit: 10,
    host: 'my ip',
    user: 'user',
    password: 'pass',,
    database: 'ssdsdas'
});

exports.pool = 池;

最佳答案

我遇到了相同的错误消息,但问题的原因可能不同。最终,我的问题的原因是我的存储过程中的列名没有反引号(`),导致它们被视为变量。

在我的存储过程主体中为列名称添加反勾修复了该问题。

关于mysql - 使用mysql应用程序在nodejs中收到无效字段长度错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40781793/

相关文章:

MySQL 将 FOR EACH 嵌套在单个触发器中而不是多个触发器中

mysql - 为什么我不能使用这个参数?

mysql - Laravel 5 - 查询生成器 AND

node.js - Jenkins "Provide Node & npm bin/folder to PATH"为空

node.js - Get对象没有方法 'executeDbCommand'

node.js - Node.js/Express 应用中的测试环境

java - JSP mysql 连接没有关闭,但是在 Java 类中它会关闭

node.js - 对 HEAD 请求使用 express sendFile

javascript - 我正在尝试使用 multer 接收视频文件并将其保存在服务器上

node.js - Firebase 工具 : login as service account