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);
}
}
}
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);
}
}
}