예제 #1
0
 private void loadCache() throws SQLException, IOException {
   Connection connection = null;
   PreparedStatement query = null;
   PreparedStatement insert = null;
   ResultSet rs = null;
   try {
     connection = dataSource.getConnection();
     query = connection.prepareStatement(SQL_GET_SEQNUMS);
     setSessionIdParameters(query, 1);
     rs = query.executeQuery();
     if (rs.next()) {
       cache.setCreationTime(SystemTime.getUtcCalendar(rs.getTimestamp(1)));
       cache.setNextTargetMsgSeqNum(rs.getInt(2));
       cache.setNextSenderMsgSeqNum(rs.getInt(3));
     } else {
       insert = connection.prepareStatement(SQL_INSERT_SESSION);
       int offset = setSessionIdParameters(insert, 1);
       insert.setTimestamp(offset++, new Timestamp(cache.getCreationTime().getTime()));
       insert.setInt(offset++, cache.getNextTargetMsgSeqNum());
       insert.setInt(offset, cache.getNextSenderMsgSeqNum());
       insert.execute();
     }
   } finally {
     JdbcUtil.close(sessionID, rs);
     JdbcUtil.close(sessionID, query);
     JdbcUtil.close(sessionID, insert);
     JdbcUtil.close(sessionID, connection);
   }
 }
예제 #2
0
 public void setNextTargetMsgSeqNum(int next) throws IOException {
   cache.setNextTargetMsgSeqNum(next);
   storeSequenceNumbers();
 }