以下jdbc代码给出错误MySQLSyntaxErrorException: You have an error in your SQL syntax;
。帮我找到它。
String selectqry="select * from raildb"+ "WHERE id=?";
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection(host,uName,uPass);
ps1=con.prepareStatement(selectqry);
ps1.setInt(1,MyModel.idno);
ResultSet rs=ps1.executeQuery();
答案 0 :(得分:3)
为查询添加空格
String selectqry="select * from raildb "+ "WHERE id=?";
^
答案 1 :(得分:1)
在 tablename 和关键字
之间的sql查询中添加空格String selectqry="select * from raildb "+ " WHERE id=?";