GetDelboxInfo.java
上传用户:liangcc
上传日期:2019-05-24
资源大小:4412k
文件大小:2k
- package com.softeem.webmail.dao.delbox;
- import java.net.ConnectException;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.util.ArrayList;
- import java.util.List;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpSession;
- import org.omg.CORBA.Request;
- import com.softeem.webmail.bean.draftbox.Draftbox;
- import com.softeem.webmail.dao.DBManager;
- /**
- * 从数据库中提取草稿信到某用户的草稿箱里
- * @author SE
- *
- */
- public class GetDelboxInfo{
- public static List getInfo(String username){
- String sql="select * from mail where (mail_to=? or mail_from=?) and box_name=?";
- String box_name="laji";
- List list = new ArrayList();
- Connection conn = DBManager.getConnection();
- try {
- PreparedStatement ps=conn.prepareStatement(sql);
- ps.setString(1, username);
- ps.setString(2, username);
- ps.setString(3, box_name);
- ResultSet rs = ps.executeQuery();
- while(rs.next()){
- Draftbox draftbox = new Draftbox();
- draftbox.setId(rs.getInt("id"));
- draftbox.setMail_from(rs.getString("mail_from"));
- draftbox.setStat(rs.getString("stat"));
- draftbox.setAdd(rs.getString("adds"));
- draftbox.setSubject(rs.getString("subject"));
- draftbox.setDate(rs.getString("date"));
- draftbox.setMail_size(rs.getString("size"));
- list.add(draftbox);
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- return list;
- }
- public static List getResult(List li,int page){
- int size = li.size();
- if(size==0){
- li = null;
- }
- else if(size%5==0){
- li = li.subList((page-1)*5, page*5);
- }else{
- int i = size/5+1;
- if(page<i){
- li = li.subList((page-1)*5, page*5);
- }else{
- li = li.subList((page-1)*5, size);
- }
- }
- return li;
- }
- }