📄 votedaoimpl.java~8~
字号:
package com.victor.dao;
import java.util.List;
import com.victor.tool.JDBConnection;
import com.victor.domain.VoteActionForm;
import java.sql.ResultSet;
import java.sql.*;
import java.util.ArrayList;
//查看投票的人物的信息
public class VoteDaoImpl
implements VoteDao {
public List selectVote() {
List list = new ArrayList();
JDBConnection connection = new JDBConnection();
VoteActionForm vote = null;
String sql = "select * from tb_Vote";
ResultSet rs = connection.executeQuery(sql);
try {
while (rs.next()) {
vote = new VoteActionForm();
vote.setID(Integer.valueOf(rs.getString(1)));
vote.setPricture(rs.getString(2));
vote.setName(rs.getString(3));
vote.setAddress(rs.getString(4));
vote.setCountry(rs.getString(5));
vote.setJop(rs.getString(6));
vote.setRemark(rs.getString(7));
vote.setNumber(Integer.valueOf(rs.getString(8)));
list.add(vote);
}
}
catch (SQLException ex) {
}
connection.close();
return list;
}
//对新闻人物的添加
public void insertVote(VoteActionForm vote) {
JDBConnection connection = new JDBConnection();
String sql = "insert into tb_vote values('" + vote.getPricture() + "','" +
vote.getName() + "','" + vote.getAddress() + "','" + vote.getCountry() +
"','" + vote.getJop() + "','" + vote.getRemark() + "',0)";
connection.executeUpdate(sql);
connection.close();
}
//对新闻人物的删除
public void deleteVote(VoteActionForm vote) {
JDBConnection connection = new JDBConnection();
String sql = "delete from tb_vote where ID='" + vote.getID() + "'";
connection.executeUpdate(sql);
connection.close();
}
//对新闻的单独查找
public List selectOneVote(VoteActionForm voteActionForm) {
List list = new ArrayList();
JDBConnection connection = new JDBConnection();
VoteActionForm vote = null;
String sql = "select * from tb_Vote where ID='" + voteActionForm.getID() +
"'";
ResultSet rs = connection.executeQuery(sql);
try {
while (rs.next()) {
vote = new VoteActionForm();
vote.setID(Integer.valueOf(rs.getString(1)));
vote.setPricture(rs.getString(2));
vote.setName(rs.getString(3));
vote.setAddress(rs.getString(4));
vote.setCountry(rs.getString(5));
vote.setJop(rs.getString(6));
vote.setRemark(rs.getString(7));
vote.setNumber(Integer.valueOf(rs.getString(8)));
list.add(vote);
}
}
catch (SQLException ex) {
}
connection.close();
return list;
}
//对新闻人物的修改
public void updateVote(VoteActionForm vote) {
JDBConnection connection = new JDBConnection();
String sql = "update tb_vote set pricture='" + vote.getPricture() +
"',Name='" + vote.getName() + "',Address='" + vote.getAddress() +
"',Country='" + vote.getCountry() + "',Job='" + vote.getJop() +
"',Number='" + vote.getNumber() + "' where ID='" + vote.getID() + "'";
connection.executeUpdate(sql);
connection.close();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -