package cn.com.dao.chivementdao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import cn.com.util.DBConnection;
import cn.com.util.DBSql;
import cn.com.vo.chivementvo.ChivementVo;
public class ExamDao {
private Connection conn = DBConnection.getConnectionOracle();
private ChivementVo examVo;
public ExamDao() {
}
public ExamDao(ChivementVo examVo) {
super();
this.examVo = examVo;
}
/**
* 全部查询
*/
public Object[][] selectAll() {
Object date[][] = null;
int max = 0;
int i = 0;
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = conn.prepareStatement(DBSql.SELECT_ALL);
rs = ps.executeQuery();
// 得到列数
max = rs.getMetaData().getColumnCount();
date = new Object[getnumberAll(DBSql.SELECT_ALL_COUNT)][max];
while (rs.next()) {
for (int j = 0; j < max; j++) {
date[i][j] = rs.getObject(j + 1);
}
i++;
}
// rs.close();
// ps.close();
// conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
return date;
}
/**
* 根据学号查询
*/
public Object[][] selectBySid() {
Object date[][] = null;
int max = 0;
int i = 0;
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = conn.prepareStatement(DBSql.SELECT_BY_S_ID);
ps.setInt(1, examVo.getS_id());
rs = ps.executeQuery();
// 得到列数
max = rs.getMetaData().getColumnCount();
date = new Object[getnumber(DBSql.SELECT_BY_S_ID_COUNT, examVo
.getS_id())][max];
while (rs.next()) {
for (int j = 0; j < max; j++) {
date[i][j] = rs.getObject(j + 1);
}
i++;
}
// rs.close();
// ps.close();
// conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
return date;
}
/**
* 根据组号查询
*/
public Object[][] selectByGid() {
Object date[][] = null;
int max = 0;
int i = 0;
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = conn.prepareStatement(DBSql.SELECT_BY_G_ID);
1