SSM连接数据库报版本错误,原因:表名用了order关键字PreparedStatementCallback; bad SQL grammar [insert into order values(?,?,?,?,?)]; nested exception is java.sql
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [insert into order values(?,?,?,?,?)]; nested exception is java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘order values(‘8001’,‘1001’,2,9998.0,‘2020-05-15 09:08:53.27’)’ at line 1一直说版本不对,一开始以为是时间的格式不对,最后发现是SQL语句写错了。@Overridepublic void add(Order order) { String sql = “insert into order values(?,?,?,?,?)”; jdbcTemplate.update(sql,order.getId(),order.getProductsId(),order.getNumber(),order.getPrice(),order.getCreateTime());}order是保留字,于是在order前面加上数据库名shopping. 就可以了。但是每次写代码都要加上表名很麻烦,我就直接把数据库的名称改了。