Bad SQL grammar exception after deploying in server

1.3k views Asked by At

I am working with MySql, Spring MVC.

When I run my code on my computer (localhost) it works fine. But after deploying it on remote server it shows Bad SQL grammar exception.

Here is screen shot from my remote server database custom error. (Screenshot from phpMyAdmin)

enter image description here

Here is the error in text formate:

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

Here is my Java code to insert data in 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;
}
1

There are 1 answers

1
JB Nizet On BEST ANSWER

OVER is a MariaDB keyword: https://mariadb.com/kb/en/library/window-functions-overview/

Rename that column to something else. I would also strongly advise using the same database in all your environments, otherwise your tests will detect bugs that don't happen in production, or won't detect bugs that happen in production.