在服务器中部署后错误 SQL 语法异常
Bad SQL grammar exception after deploying in server
我正在使用 MySql、Spring MVC。
当我 运行 我的代码在我的计算机 (localhost) 上工作正常。但在远程服务器上部署后,它显示 错误 SQL 语法异常。
这是我的远程服务器数据库自定义错误的屏幕截图。
(来自 phpMyAdmin 的屏幕截图)
这是文本格式的错误:
PreparedStatementCallback; bad SQL grammar [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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an
error in your SQL syntax; check the manual that corresponds to your
MariaDB server version for the right syntax to use near 'over, team1,
team2, toss, status, result, team_init, match_end, match_started, m'
at line 1
这是我的 Java 代码,用于在 MySql Table
中插入数据
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;
}
OVER 是 MariaDB 关键字:
https://mariadb.com/kb/en/library/window-functions-overview/
将该列重命名为其他名称。我还强烈建议您在所有环境中使用相同的数据库,否则您的测试将检测到生产中不会发生的错误,或者不会检测到生产中发生的错误。
我正在使用 MySql、Spring MVC。
当我 运行 我的代码在我的计算机 (localhost) 上工作正常。但在远程服务器上部署后,它显示 错误 SQL 语法异常。
这是我的远程服务器数据库自定义错误的屏幕截图。 (来自 phpMyAdmin 的屏幕截图)
这是文本格式的错误:
PreparedStatementCallback; bad SQL grammar [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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'over, team1, team2, toss, status, result, team_init, match_end, match_started, m' at line 1
这是我的 Java 代码,用于在 MySql Table
中插入数据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;
}
OVER 是 MariaDB 关键字: https://mariadb.com/kb/en/library/window-functions-overview/
将该列重命名为其他名称。我还强烈建议您在所有环境中使用相同的数据库,否则您的测试将检测到生产中不会发生的错误,或者不会检测到生产中发生的错误。