0

我正在使用 MySql,Spring MVC。

当我在我的计算机(本地主机)上运行我的代码时,它工作正常。但在远程服务器上部署后,它显示Bad SQL syntax exception

这是我的远程服务器数据库自定义错误的屏幕截图。(来自 phpMyAdmin 的屏幕截图)

在此处输入图像描述

这是文本格式的错误:

PreparedStatementCallback; 错误的 SQL 语法 [插入匹配项(id、title、location、number_of_players、over、team1、team2、toss、status、result、team_init、match_end、match_started、match_views、书签、公告、锦标赛、create_date、start_date、active_date、asst_scorer、 start_date_string) 值 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; 嵌套异常是 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; 检查与您的 MariaDB 服务器版本相对应的手册,以在第 1 行的 'over, team1, team2, toss, status, result, team_init, match_end, match_started, m' 附近使用正确的语法

这是我在 MySql 表中插入数据的 Java 代码

public boolean createMatch(Match match) {

    BeanPropertySqlParameterSource params = new BeanPropertySqlParameterSource(match);

    return jdbc.update(
        "insert into matchs (id, title, location, number_of_players, over, team1, team2, toss, status, result, team_init, match_end, match_started, match_views, bookmarked, announcement, tournament, create_date, start_date, active_date, asst_scorer, start_date_string) values (:id, :title, :location, :number_of_players, :over, :team1, :team2, :toss, :status, :result, :team_init, :match_end, :match_started, :match_views, :bookmarked, :announcement, :tournament, :create_date, :start_date, :active_date, :asst_scorer, :start_date_string)",
        params) == 1;
}
4

1 回答 1

3

OVER 是 MariaDB 关键字: https ://mariadb.com/kb/en/library/window-functions-overview/

将该列重命名为其他名称。我还强烈建议在您的所有环境中使用相同的数据库,否则您的测试将检测到生产中不会发生的错误,或者不会检测到生产中发生的错误。

于 2017-10-14T10:08:50.277 回答