QueryNewBox.java
上传用户:liangcc
上传日期:2019-05-24
资源大小:4412k
文件大小:1k
- package com.softeem.webmail.dao.folder;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import com.softeem.webmail.dao.DBManager;
- public class QueryNewBox {
- private Connection conn;
-
- private PreparedStatement ps;
-
- private ResultSet rs;
-
- public int [] queryByBoxName(String stat,String username){
- // System.out.println(username+"*************");
- conn = DBManager.getConnection();
- int [] counts = new int[2];
- String sql = "select count(*),sum(size) from mail where stat = ? and mail_to = ?";
- try {
- ps = conn.prepareStatement(sql);
- ps.setString(1, stat);
- ps.setString(2,username);
- rs = ps.executeQuery();
- while(rs.next()){
- counts[0] = rs.getInt(1);
- counts[1] = rs.getInt(2);
- return counts;
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }finally{
- DBManager.closeConnection(rs, ps, conn);
- }
- return null;
- }
-
- // public static void main(String[] args) {
- // new Query().queryByBoxName("recbox");
- // }
- }