谁能帮我看看查询语句条件有什么问题?
我写的sql语句:
Connection conn = DBUtil.getConnection();
String sql = ""+
" select * from imooc_goddess where id = ?";
PreparedStatement ptmt = conn.prepareStatement(sql);
ptmt.setInt(1, id);
好像没什么问题呀,直接在mysql中可以查出数据,但执行时报错:
Exception in thread "main" 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 '?' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
这个”?“有什么问题?