[Err] com. Microsoft. sqlserver. JDBC. sqlserverexception: The result set does not have the current row.

Source: Internet
Author: User

 

Java obtains the result set, if (RS! = NULL), which is different from while (Rs. Next ().

 

Com. Microsoft. sqlserver. JDBC. sqlserverexception: The result set does not have the current row. <Br/> ST = conn. createstatement (); <br/> resultset rs = st.exe cutequery (SQL); <br/> If (RS! = NULL) {// Rs. next (); <br/> system. out. println (RS. getrow (); <br/> system. out. println (RS. getstring ("name"); </P> <p >}< br/> ST = Conn. createstatement (); <br/> resultset rs = st.exe cutequery (SQL); <br/> while (RS. next () {// Rs. next (); <br/> system. out. println (RS. getrow (); <br/> system. out. println (RS. getstring ("name"); </P> <p>} 

Cause: the RS position of the result set is located at the beginning of the first record, that is, 0. Therefore, when the if clause is used for determination, the current behavior of the result set is null.

This is a problem that the resultset points to. After the resultset value is set, the pointer defaults to the first element whose index is-1,

That is, before the first element in the resultset, the pointer points to a non-existent element by default, so an error occurs. You must call the. Next () function to traverse the resultset.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.