This might be more what you were after though:
| /**
| * Get the emails that have not been sent yet. This email contains
| * a recipient list of 1 IndividualRecipient.
| *
| * @param since the time to look for new emails since, this
| * is a performance optimization, witout it
| * the query would need to look at all message
| * records, with it the query only needs to look
| * at message records in a range.
| */
| public Email[] getEmailsToSend(long since) {
|
|
| String sql =
| " SELECT m.msg_id, "
| + " m.subject, m.return_address, m.body_text, m.delivery_date,
m.msg_category_id "
| + " FROM message m "
| + " WHERE m.notification_type_id = " +
MessagingConstants.NOTIF_TYPE_EMAIL
| + " and m.status_id not in ( "
| + MessagingConstants.MESSAGE_STATUS_DRAFT + ","
| + MessagingConstants.MESSAGE_STATUS_SENT + ", "
| + MessagingConstants.MESSAGE_STATUS_INACTIVE + ", "
| + MessagingConstants.MESSAGE_STATUS_QUEUING + " ) "
| + " and m.delivery_date between (? -(1/24)) and sysdate "; //check
between the last hour the email daemon ran
| //and the
current time for the case where emails
| //are
created at midnight. mhc 11/12/03
|
| LmnkConnection conn = null;
|
| try {
| conn = ConnectionFactory.createLmnkConnection();
|
| Object[] args = new Object[]{ new Timestamp(since) };
| LmnkStatement stmt = conn.prepareStatement(sql, args);
| //PreparedStatement stmt = conn.prepareStatement(sql);
|
| ResultSet rs = stmt.executeQuery();
|
| ArrayList result = new ArrayList(64);
| while (rs.next()) {
| //recipients will be filled in later
| Email email = new Email(null, rs.getString(2), rs.getString(3));
| email.setMessageId(rs.getLong(1));
| email.setBodyText(rs.getString(4));
| email.setDeliveryDate(rs.getTimestamp(5));
| email.setType( MessageType.createFromConstant(rs.getInt(6)));
| result.add(email);
| }
|
| Email[] emailsToSend = (Email[])result.toArray(new Email[result.size()]);
|
| /*
| * print out the emails being sent.
| */
| if ( log.isDebugEnabled() ) {
| if ( emailsToSend.length > 0 ) {
| StringBuffer sb = new StringBuffer();
| for ( int i = 0; i < emailsToSend.length; i++){
| sb.append( emailsToSend.getMessageId() );
| if ( i < emailsToSend.length ){
| sb.append(",");
| }
| }
| log.debug( "sending [" + sb.toString() + "]" );
| }
| }
|
| return emailsToSend;
|
| } catch ( SQLException e ){
| log.error("Failed to execute sql:\n" + sql , e);
| throw new DalRuntimeException(e.getMessage());
| } finally {
| if ( conn != null) conn.close();
| }
| }
|
|
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3842295#3842295
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3842295
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user