java.sql.SQLException: After end of result set in mysql

后端 未结 2 592
执念已碎
执念已碎 2020-12-04 02:14

I am trying to Download image (.png) file from MYSQL. some time it works fine.unable find exact problem. it works properly on Jboss server. throws an error while trying to r

相关标签:
2条回答
  • 2020-12-04 02:29

    The second result.next is moving you past the end of the result set.

    I think you want

    result = st.executeQuery();
    if(result.next()){
       input = result.getAsciiStream(1);
    }
    
    0 讨论(0)
  • 2020-12-04 02:36

    You are calling result.next() twice. I'm assuming that your query returns only 1 row since you are trying to match by Userid. When the second result.next() is being called, there is no row to be returned in the ResultSet. This is why an SQLException is being thrown. Remove the 1st result.next() like so:

    result = st.executeQuery();
    if(!result.next()){
        input = result.getAsciiStream(1);
        }
    
    0 讨论(0)
提交回复
热议问题