Java.sql.SQLException: Off the Resultset:next

Source: Internet
Author: User

Judging by the exception information is the result set of the database query is closed, so the next

My code is a Impl method (assumed to be a method) call another Impl method (assuming the B method), I after the execution of the B method, called the method of closing the database connection, the result of a method connected to the database closed;

The workaround is to turn off the database connection method in the B method (ie: Super.close (con, pstmt, NULL, RS);) to delete it!

Here's my code for the error:

/**
* Query for deferred tasks
*/
@Override
Public list<extension> Findplantask (String itemId) {
con = super.getconnection ();
List<extension> plantasklist=new arraylist<extension> ();
Extension Extension=null;
String sql= "Select Yq_yjtzrq,yq_rwbh from Qj_extension where yq_xmbh=?";
try{
Pstmt=con.preparestatement (SQL);
Pstmt.setstring (1, itemId);
Rs=pstmt.executequery ();
while (Rs.next ()) {

Extension=new extension ();
EXTENSION.SETYJTZRQ (rs.getstring ("Yq_yjtzrq"));
Plantask plantask= Selectplantask (rs.getstring ("YQ_RWBH"));
Extension.setplantask (Plantask);
Plantasklist.add (extension);
}
}catch (SQLException e) {
E.printstacktrace ();
}
Super.close (con, pstmt, NULL, RS);
return plantasklist;
}


/**
* Query tasks based on the ID of the deferred plan
* @param pid
* @return
*/
Private Plantask Selectplantask (String pid) {
con = super.getconnection ();
Plantask Plantask=null;
String sql= "Select Plantask_rwbh,plantask_rwzt,plantask_rwjc,plantask_jcms,plantask_rwlb,plantask_rwmc,plantask_ Jhksrq,plantask_jhwcrq from Qj_plantask where plantask_jhbh=? ";
try{
Pstmt=con.preparestatement (SQL);
Pstmt.setstring (1, PID);
Rs=pstmt.executequery ();
while (Rs.next ()) {
Plantask=new Plantask ();
PLANTASK.SETPLANTASKRWBH (rs.getstring ("PLANTASK_RWBH"));
Plantask.setplantaskrwzt (rs.getstring ("Plantask_rwzt"));
PLANTASK.SETPLANTASKRWJC (Rs.getint ("PLANTASK_RWJC"));
Plantask.setplantaskjcms (rs.getstring ("Plantask_jcms"));
PLANTASK.SETPLANTASKRWLB (rs.getstring ("PLANTASK_RWLB"));
PLANTASK.SETPLANTASKRWMC (rs.getstring ("PLANTASK_RWMC"));
PLANTASK.SETPLANTASKJHKSRQ (rs.getstring ("PLANTASK_JHKSRQ"));
PLANTASK.SETPLANTASKJHWCRQ (rs.getstring ("Plantask_jhwcrq"));
}
}catch (SQLException e) {
E.printstacktrace ();
}

Super.close (con, pstmt, NULL, RS);
return plantask;
}

Java.sql.SQLException: Off the Resultset:next

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.