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 ‘from customers where id=2’ at line 1
我的问题是:
public void test(){
String sql="select from customers where id=?";
System.out.println(querForCustomers(sql,2));
}
``
不知道有没有细心人看出来???
,然后看了一下网上教程
其实这个异常主要是SQL语法出错引起的。
1、表名或者字段名是不是使用了Mysql的关键字,比如 join、on、order、from…
2、SQL语句多写了一些符号比如 ‘ ’或者 ; 如上我就是在表名上多加了 ‘ ’ 符号`
3、就是自己书写的内容没有书写完整。上面就是SQL语法没有问题,但是没有说明select具体查询的内容是什么???
大家还是要好好学习一下数据库的内容,还是很有用的。