ResultSet exception - before start of result set

后端 未结 6 938
独厮守ぢ
独厮守ぢ 2020-11-21 23:30

I\'m having trouble getting data from a ResultSet object. Here is my code:

    String sql = \"SELECT type FROM node WHERE nid = ?\";
    PreparedStatement pr         


        
6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 00:34

    Every answer uses .next() or uses .beforeFirst() and then .next(). But why not this:

    result.first();
    

    So You just set the pointer to the first record and go from there. It's available since java 1.2 and I just wanted to mention this for anyone whose ResultSet exists of one specific record.

提交回复
热议问题