o00000000

package com.goby.editor;

import java.sql.PreparedStatement;
import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.goby.Constant;
import com.goby.Current;
import com.goby.Mapx;
import com.goby.Mysql_Conn;
import com.util.DateUtil;

public class Vote extends Current {
	public void add() {
		try {
			Mapx mapx = (Mapx) getMapx();
			String sql = "insert into zcvote(id,title,IPLimit,starttime,endtime,total) values(?,?,?,?,?,?)";
			Mysql_Conn conn = new Mysql_Conn();
			PreparedStatement pstmt = conn.getConnection(Constant.DATABASE)
					.prepareStatement(sql);
			pstmt.setString(1, NoUitl.getMaxNoLoal("zcvote"));
			pstmt.setString(2, mapx.getString("Title"));
			pstmt.setString(3, mapx.getString("IPLimit"));
			
			Date startdate = DateUtil.parse(mapx.getString("StartDate")+":00", "yyyy-MM-dd HH:mm:ss");
			Date EndDate = DateUtil.parse(mapx.getString("EndDate")+":00", "yyyy-MM-dd HH:mm:ss");
			System.out.println("开始时间:"+startdate.getTime());
			pstmt.setTimestamp(4, new Timestamp(startdate.getTime()));
			pstmt.setTimestamp(5, new Timestamp(EndDate.getTime()));
			pstmt.setInt(6, 0);
		
			pstmt.executeUpdate();
			Map item = new HashMap();
			item.put("message", "add success");
			mapx.setItem(item);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}

	}
}
 

你可能感兴趣的:(java,sql,mysql)