Query is returning a value but the controller is not entering into resultset

10 pts.
Tags:
feasibility.jsp

public Map fetchSharedValues1(String servItemCode) throws AppException{

Connection conn = null;

String successFlag="";

PreparedStatement pstmt = null;

String sharedServId = null;

Map map = new HashMap();

ResultSet rs = null;

String feasibilityId = null;

String objQuery="select fi1.item_code from fsb_item fi, fsb_item fi1" +

" where fi.item_code = ? " +

" and fi.linkage = fi1.item_seq_id ";

String feasibilityIdQuery = "select fi.feasibility_id from fsb_item fi where fi.item_code = ?";

try {

conn = getConnection(Constants.CORP_POS_DATASOURCE);

conn.setAutoCommit(false);

pstmt = conn.prepareStatement(objQuery);

pstmt.setString(1, servItemCode);

System.out.println("objQuery from dao is::::"+objQuery);

System.out.println("servItemCode from dao is::::"+servItemCode);

rs = pstmt.executeQuery();

while (rs.next()) {

sharedServId = rs.getString(1);

System.out.println("valueis::"+sharedServId);

}

pstmt = conn.prepareStatement(feasibilityIdQuery);

pstmt.setString(1, servItemCode);

System.out.println("item is::"+servItemCode);

rs = pstmt.executeQuery();

while (rs.next()) {

feasibilityId = rs.getString(1);

System.out.println("fi is::"+feasibilityId);

}

if (sharedServId != null && feasibilityId!= null) {

map.put("sharedServId", sharedServId);

map.put("feasibilityId", feasibilityId);

System.out.println("ssid is::"+sharedServId);

System.out.println("ffid is ::"+feasibilityId);

}

else

{

throw new AppException("No Shared Details available for the Service Id :"+servItemCode);

}

logger.info(" successFlag = "+successFlag);

conn.commit();

} catch (SQLException se) {

ExceptionHandler.handleException("Database Exception while updating DataChanged Values ", se);

} finally {

cleanUp(conn, pstmt);

}

return map;

}



Software/Hardware used:
eclipse

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    Can you describe what your problem is? The code is too confusing. It doesn't make much sense.   For example, what are you committing? Why would you use rs for both queries? Why do you have two separate queries? And why do you need a HashMap() if you're only getting two values?   But most of all, what problem are you asking about?   Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following