错误You have an error in your SQL syntax; check the manual that corresponds to your MySQL

查询数据库数据表的时候,一个简单的sql查询语句,可是一直报错,说我的sql语句错误:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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' at line 1

可是就这个简单的查询语句怎么会错呢,于是我换成其他表名,居然又能运行下去,才惊觉!!!我写的代码:

pStmt = con.prepareStatement("select * from order");

rs = pStmt.executeQuery();

中我的表名为order,与sql语句中order关键字重了!

表名一定不能与关键字相同!

虽然是一个小错误,可是困扰了我一下午,还是决定分享一下给像我一样迷糊的同学(~ ̄▽ ̄)~ 

猜你喜欢

转载自blog.csdn.net/start_XUEBA/article/details/80721190