⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 selectdao.java

📁 一个非常好的投票系统,可以用来参考扩展成商用投票系统
💻 JAVA
字号:
package com.vote.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import com.vote.vo.SelectVO;
import com.vote.dto.SelectDTO;
import com.vote.interfacer.SelectInterface;

public class SelectDAO implements SelectInterface {

	public int AddVoteItem(Connection con, SelectDTO selectDTO) throws SQLException {
		// TODO Auto-generated method stub
		String strSQL="insert into selected(Vote_selected_name,Vote_id,Vot_time) values ( ?,?,?)";
		System.out.println(strSQL);
		PreparedStatement ps = con.prepareStatement(strSQL);
		int nIndex = 1;
		ps.setString(nIndex++, selectDTO.getVote_selected_name());
		ps.setInt(nIndex++, selectDTO.getVote_id());
		ps.setString(nIndex++, selectDTO.getVot_time());
		return ps.executeUpdate();
	}

	public int DeleteVoteItem(Connection con, int Vote_Selected_id) {
		// TODO Auto-generated method stub
		return 0;
	}

	public ArrayList OneVoteItem(Connection con, int Vote_Selected_id) {
		// TODO Auto-generated method stub
		return null;
	}

	public ArrayList ShowVoteItem(Connection con, int Vote_id) throws SQLException {
		// TODO Auto-generated method stub
		String strSQL=" select * from selected where Vote_id= ?";
		PreparedStatement ps = con.prepareStatement(strSQL);
		System.out.println(strSQL);
		int nIndex = 1;
		ps.setInt(nIndex++,  Vote_id);
		ResultSet rs = ps.executeQuery();
		ArrayList alist = new ArrayList();
		while(rs!=null&&rs.next())
		{
			SelectVO selectVO = new SelectVO();
			selectVO.setVote_id(rs.getInt("Vote_selected_id"));
			selectVO.setVote_selected_name(rs.getString("Vote_selected_name"));
			selectVO.setVot_time(rs.getString("Vot_time"));
			selectVO.setVote_selected_count(rs.getInt("Vote_selected_count"));
			selectVO.setVote_id(Vote_id);
			alist.add(selectVO);
		}	
		ps.close();
		rs.close();
		con.close();
		return  alist;
	}

	public int UpdateVoteItem(Connection con, int Vote_Selected_id) {
		// TODO Auto-generated method stub
		return 0;
	}

	public int UserVote(Connection con, int Vote_id) {
		// TODO Auto-generated method stub
		return 0;
	}




}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -