📄 subject_question_difficultdao.java
字号:
package dao;
import java.sql.*;
import java.util.ArrayList;
import vo.Subject_Question_DifficultVO;
public class Subject_Question_DifficultDAO
{
private Connection conn = null;
private Statement state = null;
private ResultSet rs = null;
//查询全部试题
public ArrayList findAlls_q_dByCid(int pageSize,int startRows,int cid)
{
ArrayList array = new ArrayList();
conn = Tools.getConnection();
try {
state = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs = state.executeQuery("select * from subject,question,difficult where subject.cid=question.cid and question.cid="+cid);
rs.absolute(startRows);
for(int i=0;i<pageSize;i++)
{
Subject_Question_DifficultVO sqdvo = new Subject_Question_DifficultVO();
sqdvo.setCid(rs.getInt("cid"));
sqdvo.setCname(rs.getString("cname"));
sqdvo.setAnswer(rs.getString("answer"));
sqdvo.setDid(rs.getInt("did"));
sqdvo.setDname(rs.getString("dname"));
sqdvo.setFlag(rs.getString("flag"));
sqdvo.setQuestion(rs.getString("question"));
sqdvo.setOptionA(rs.getString("optionA"));
sqdvo.setOptionB(rs.getString("optionB"));
sqdvo.setOptionC(rs.getString("optionC"));
sqdvo.setOptionD(rs.getString("optionD"));
sqdvo.setQid(rs.getInt("qid"));
sqdvo.setQscore(rs.getInt("qscore"));
array.add(sqdvo);
if(!rs.next())
break;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally{
try {
if(rs != null)
rs.close();
if(state != null)
state.close();
if(conn != null)
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return array;
}
//返回总行数
public int ReturnTotalRows()
{
int totalRows = 0;
try {
conn = Tools.getConnection();
state= conn.createStatement();
rs = state.executeQuery("select count(*) con from subject,question,difficult where subject.cid = question.cid");
if(rs.next())
{
totalRows = rs.getInt("con");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
try {
if(rs != null)
rs.close();
if(state != null)
state.close();
if(conn != null)
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return totalRows;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -