SaveDAO.java
上传用户:liangcc
上传日期:2019-05-24
资源大小:4412k
文件大小:1k
- package com.softeem.webmail.dao.save;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
- import java.util.Date;
- import com.softeem.struts.form.WriteForm;
- import com.softeem.webmail.dao.DBManager;
- public class SaveDAO {
- public void savedao(WriteForm wf,String name){
- Connection con = DBManager.getConnection();
- PreparedStatement ps = null;
- String sql = "insert into mail(mail_from,mail_to,subject,date,content,box_name,stat,adds,size) values(?,?,?,?,?,?,?,?,?)";
- try {
- ps = con.prepareStatement(sql);
- ps.setString(1, name);
- ps.setString(2, wf.getToUser());
- ps.setString(3, wf.getSubject());
- ps.setString(4, new Date().toString());
- ps.setString(5, wf.getRichedit());
- ps.setString(6, "sendbox");
- //状态要写活
- ps.setString(7, "1");
- //是否有附件要写活
- if (wf.getFiles() != null) {
-
- ps.setString(8, "1");
- }else{
- ps.setString(8, "0");
- }
- //邮件大小要写活
- ps.setDouble(9, wf.getRichedit().length());
- ps.execute();
- } catch (SQLException e) {
- e.printStackTrace();
- }finally{
- DBManager.closeConnection(null, ps, con);
- }
- }
- }