Here the method reads the database which has an unique ID with the sequence number which keeps on increasing, since am a beginner in java,can I know how to implement this repetitive polling and check for new incoming message each time.
/** * Method which defines polling of the database and also count the number of Queries * @return pojo collection * @throws Exception */ public List<KAMessage> fullPoll() throws Exception { Statement st = dbConnection.createStatement(); ResultSet rs = st.executeQuery("select * from msg_new_to_bde where ACTION = 804 order by SEQ DESC"); List<KAMessage> pojoCol = new ArrayList<KAMessage>(); while (rs.next()) { KAMessage filedClass = convertRecordsetToPojo(rs); pojoCol.add(filedClass); } return pojoCol; } /** * Converts a provided record-set to a {@link KAMessage}. * * The following attributes are copied from record-set to pojo: * * <ul> * <li>SEQ</li> * <li>TABLENAME</li> * <li>ENTRYTIME</li> * <li>STATUS</li> * </ul> * * @param rs * @return the converted pojo class object * @throws SQLException * */ private KAMessage convertRecordsetToPojo(ResultSet rs) throws SQLException { KAMessage msg = new KAMessage(); int sequence = rs.getInt("SEQ"); msg.setSequence(sequence); int action = rs.getInt("ACTION"); msg.setAction(action); String tablename = rs.getString("TABLENAME"); msg.setTableName(tablename); Timestamp entrytime = rs.getTimestamp("ENTRYTIME"); Date entryTime = new Date(entrytime.getTime()); msg.setEntryTime(entryTime); Timestamp processingtime = rs.getTimestamp("PROCESSINGTIME"); if (processingtime != null) { Date processingTime = new Date(processingtime.getTime()); msg.setProcessingTime(processingTime); } String keyInfo1 = rs.getString("KEYINFO1"); msg.setKeyInfo1(keyInfo1); String keyInfo2 = rs.getString("KEYINFO2"); msg.setKeyInfo2(keyInfo2); return msg; } }