【java.sql.SQLException: Before start of result set】

将ResultSet转换为 Map<String,String>时抛出了一个这样的异常:java.sql.SQLException: Before start of result set

网上查了下,说是必须这么写:
1 while (rs.next()){
2 
3     ...    ...
4 }

具体为何必须这么写呢?stackoverflow上面的阿三大兄弟给出了答案:java

Would it be safe to use result.next() or result.first() when executing a simple COUNT query because it should never be null and will only ever be 1 result.sql

翻译:使用 result.next() or result.first() 为了保证安全,由于它永远不该该为null而且结果只会是1;安全

原文地址:https://stackoverflow.com/questions/2120255/resultset-exception-before-start-of-result-setspa

吐槽:浓浓的咖喱味英语  呕~~~翻译

相关文章
相关标签/搜索