我正在使用 mySQL。正如您所看到的,SELECT
处的 SQL 语句是错误的。那么,我想知道 rs 的值是多少?
我希望得到一些建议。非常感谢您;
String sql = "SELCT * FROM user WHERE username = '" + username + "' and password = '" + password + "'";
ResultSet rs = stm.executeQuery(sql);
最佳答案
没有任何值(value),因为 Statement.executeQuery(String)
会抛出 SQLException
。正如链接的 Javadoc 所说,
Returns: a
ResultSet
object that contains the data produced by the given query; nevernull
Throws:
SQLException
- if a database access error occurs, this method is called on a closedStatement
, the given SQL statement produces anything other than a singleResultSet
object, the method is called on aPreparedStatement
orCallableStatement
关于java - SQL语句语法错误时ResultSet的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53983845/