我正在使用Spring MVC的MySql。在服務器中部署後出現錯誤的SQL語法異常
當我在我的電腦(localhost)上運行我的代碼時,它工作正常。但是,在遠程服務器上部署它之後,它會顯示錯誤的SQL語法異常。
這是從我的遠程服務器數據庫自定義錯誤的屏幕截圖。 (截圖從phpMyAdmin的)
以下是在文本甲酸錯誤:
PreparedStatementCallback;錯誤的SQL語法[插入到匹配中( 公告,比賽,create_date,start_date,active_date) ,?,?,?,?,?,?,?,?,?,?,? asst_scorer,start_date_string) ,?)];嵌套的異常是 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的SQL語法中有一個 錯誤;檢查位於第1行
對應於你的 MariaDB的服務器版本正確的語法使用近 '了,TEAM1, TEAM2,折騰,狀態,結果,team_init,match_end,match_started,M' 手冊這是我的Java代碼中插入數據在MySQL表
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;
}
這個問題被標記爲Mysql,但堆棧跟蹤屬於MariaDb,你是否在本地主機和遠程運行不同的數據庫服務器? –
是的不同的mysql服務器 –
你應該在本地和生產環境中運行相同的環境。這樣你就可以避免這種問題。 –