“_latin”在每个参数之前连接起来
java代码:
PreparedStatement prepStmt = null;
QueryString = "SELECT FROM Student WHERE username=? AND password=? ";
prepStmt=con.prepareStatement(QueryString);
prepStmt.setString(1,un);
prepStmt.setString(2,pwd);
ResultSet rs;
System.out.println(prepStmt);
rs = prepStmt.executeQuery();
错误:
java.sql.SQLException: [MySQL][ODBC 5.1 Driver][mysqld-5.5.24-log]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 Student WHERE username=_latin1'wow' AND password=_latin1'hell'' at line 1
为什么会发生这种情况,解决方案是什么
这是表:
答案 0 :(得分:0)
您缺少查询中的列列表。您必须明确指定所需的列,或通过通配符检索所有列。而不是:
SELECT FROM Student WHERE username = ? AND password = ?
你想要这样的东西:
SELECT * FROM Student WHERE username = ? AND password = ?
请注意,显式定义要检索的列几乎总是更好,而不是使用通配符表达式。