日期:2014-05-18 浏览次数:20940 次
package com.chk.doubleball.action;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.chk.doubleball.model.Bonus;
import com.chk.doubleball.util.DBUtil;
import com.opensymphony.xwork2.ActionSupport;
public class DoubleBallAction extends ActionSupport {
private static final long serialVersionUID = 2379238399721987661L;
public String doubleballAction() {
// 第一步:查询数据
List<Bonus> bonusList = new ArrayList<>();
String sql = "select * from t_bonus where _id > (select count(*) from t_bonus) - 100;";
Connection conn = DBUtil.getConn();
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next()) {
Bonus d = new Bonus();
d.set_id(rs.getInt("_id"));
d.setIssue(rs.getInt("issue"));
d.setDates(rs.getDate("dates"));
d.setOrder_red_one(rs.getString("order_red_one"));
d.setOrder_red_two(rs.getString("order_red_two"));
d.setOrder_red_three(rs.getString("order_red_three"));
d.setOrder_red_four(rs.getString("order_red_four"));
d.setOrder_red_five(rs.getString("order_red_five"));
d.setOrder_red_six(rs.getString("order_red_six"));
d.setBlue(rs.getString("blue"));
d.setSequence_red_one(rs.getString("sequence_red_one"));
d.setSequence_red_two(rs.getString("sequence_red_two"));
d.setSequence_red_three(rs.getString("sequence_red_three"));
d.setSequence_red_four(rs.getString("sequence_red_four"));
d.setSequence_red_five(rs.getString("sequence_red_five"));
d.setSequence_red_six(rs.getString("sequence_red_six"));
d.setTotal_amount(rs.getInt("total_amount"));
d.setBonuses_balance(rs.getInt("bonuses_balance"));
d.setFirst_prize_number(rs.getInt("first_prize_number"));
d.setFirst_prize_money(rs.getInt("first_prize_money"));
d.setSecond_prize_number(rs.getInt("second_prize_number"));
d.setSecond_prize_money(rs.getInt("second_prize_money"));
d.setThird_prize_number(rs.getInt("third_prize_number"));
d.setThird_prize_money(rs.getInt("third_prize_money"));
d.setFourth_prize_number(rs.getInt("fourth_prize_number"));
d.setFourth_prize_money(rs.getInt("fourth_prize_money"));
d.setFifth_prize_number(rs.getInt("fifth_prize_number"));
d.setFifth_prize_money(rs.getInt("fifth_prize_money"));
d.setSixth_prize_number(rs.getInt("sixth_prize_number"));
d.setSixth_prize_money(rs.getInt("sixth_prize_money"));
bonusList.add(d);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
DBUtil.close(rs);
DBUtil.close(pstmt);
DBUtil.close(conn);
}
return SUCCESS;
<