Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not getting the alternate from if else

Status
Not open for further replies.

Ngai88

Programmer
Sep 8, 2004
56
US
Hello,
Can anyone tell me what I am missing in the following? In getMsgStatusAsString, it calls method 'isFRecipientAck'. When it returns row count 0, the field should show 'UNREAD', if row count returns 1, then it should show 'READ'.
Right now all it does is showing 'UNREAD', I tested it with row count = 1 but it still shows up as 'UNREAD'. I re-ran the field again many times, it still shows 'UNREAD'.
Do I have to do something after the if else to call it again?

Thanks,
Ngai.

===========================================================
private String getMsgStatusAsString(MsgLogBean msgLog) throws CrisisControllerException {
if (isMsgOverDue(msgLog.getTimeSent())) {
// show 'OVERDUE'
return MSG_STATUS_OVERDUE;
} else {
if (isFRecipientAck(msgLog)) {
//show 'READ'
return MSG_STATUS_READ;
} else {
//show 'UNREAD'
return MSG_STATUS_UNREAD;
}
}
}
======================================================
public boolean isFRecipientAck(String msgId, int incidentId) throws DBException {
DBConnection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
conn = getConnection(getClass().getName());
pstmt = conn.createPreparedStatement(SEL_FRECIPIENT);
pstmt.setString(1, msgId);
pstmt.setInt(2, incidentId);
rs = pstmt.executeQuery();
int count = 0;
if (rs.next()) {
count = rs.getInt(1);
}

// when it return row count 0,
// getMsgStatusAsString should show 'UNREAD',
// if row count return 1, then it should show 'READ'.

return(count >= 1);
} catch (SQLException ex) {
throw new DBException("SQL Exception occurred while message acknowledgement time from database.\n" + ex);
} finally {
try {
if (pstmt != null) {
pstmt.close();
}
} catch (SQLException ex) {}

if (localConnection == null) {
myPool.release(conn);
}
}
}
 
Hi Stefan,

I spent sometime looking at boolean isFRecipientAck the code that calls the database with the following Select statement.

SEL_RECIPIENT =
"SELECT COUNT(ACK.ACK_O)
FROM CMS_MSG_ACK ACK, CMS_MSG_LOG LOG
WHERE ACK.MSG_ID = LOG.MSG_ID
AND ACK.INCIDENT_ID = LOG.INCIDENT_ID
AND ACK.MSG_ID = ?
AND ACK.INCIDENT_ID = ?
AND ACK.ACK_O = 'Y'
and ACK.FUNCTION_NAME = SUBSTR(LOG.RECIPIENT, 1, INSTR(LOG.RECIPIENT, '<br>') - 1)";

the way this select statement set up is to use the row count as an indicator to decide the display GUI when to turn on UNREAD or READ.

I use debug logs to trap the count to see if it is doing its job, it does not look like the count is switching back from '0' to '1' and visa versa.

The intention of boolean isFRecipientAck is ....
if the ACK_O = 'Y' , the count is 0, here 0 means primary
recipient has not read the mail yet, should show 'UNREAD'.

if the ACK_O = 'N' , the count is 1, here 1 means primary
recipient has read the mail, then it should show 'READ'.

Right now, it doesn't matter how I test the 1, or 0, the log
file shows the count is 0 all the time, that's why it is
showing 'UNREAD' all the time.

I am wondering if the way I set up my count is incorrect?

thanks,
Ngai

 
Thanks Stefan,
I tracked it and found out that somehow the incident_id = blank, nothing get passed in. My oversight.


thanks,
Ngai
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top