📄 readmailbody.java
字号:
/**
* Created at Dec 10, 2008
*/
package com.jdev.app.db;
import java.sql.ResultSet;
import com.jdev.db.ConnectPool;
import com.jdev.net.connector.ConnectionFactory;
import com.jdev.net.event.Notifier;
import com.jdev.util.Debug;
/**
* <p>Title: ReadMailBody</p>
* <p>Description: </p>
* @author Lawrence
* @version 1.0
*/
public class ReadMailBody implements Runnable {
protected Notifier notifier;
private java.sql.Connection conn;
private EmailQueueHelper emailDataHelper;
private ConnectPool connectionManager;
private final static String module = ReadMailBody.class.getName();
/**
*
*/
public ReadMailBody() {
notifier = Notifier.getNotifier();
connectionManager = ConnectPool.getInstance();
emailDataHelper = new EmailQueueHelper(ConnectionFactory.CLIENT);
}
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run() {
try {
conn = connectionManager.getConnection("test");
} catch (Exception e) {
notifier.fireOnError("-->Error occured in ReadMailText openDb: "
+ e.getMessage());
}
while(!Thread.interrupted()) {
try {
if (conn == null || conn.isClosed()) {
Thread.sleep(10000);
try {
conn = connectionManager.getConnection("test");
} catch (Exception e) {
notifier.fireOnError("-->Error occured in DbReader openDb: "
+ e.getMessage());
}
continue;
}
getMailBody();
// conn.close();
Thread.sleep(120000);
} catch (Exception e) {
continue;
}
}
}
private void getMailBody() {
try {
java.sql.Statement stmt = conn.createStatement();
ResultSet rs = null;
// 判断是否存在
StringBuilder strSelect = new StringBuilder("select * from PUSH_MAIL_MSG ");
rs = stmt.executeQuery(strSelect.toString());
while(rs.next()){
String str = rs.getString(1);
if(emailDataHelper.findBody(str)) {
continue;
}
StringBuilder str2 = new StringBuilder(str
+ ";" + rs.getString(2) + ";" + rs.getString(3)+";"+rs.getString(6));
// Debug.logVerbose(str2.toString());
emailDataHelper.writeBody(str2.toString());
}
stmt.close();
} catch (Exception e) {
Debug.logError(e,module);
}
}
public static void main(String[] args) throws Exception {
try {
ReadMailBody d = new ReadMailBody();
Thread s = new Thread(d);
s.start();
// EmailPush emailPush = new EmailPush("","");
// Thread e = new Thread(emailPush);
// e.start();
} catch (Exception e) {
throw new Exception(e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -