📄 votedaoimpl.java~4~
字号:
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();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -