📄 subject_studentdao.java
字号:
package business;
import java.sql.*;
import java.util.ArrayList;
import po.RelationPO;
public class Subject_StudentDAO
{
private Connection conn = null;
private Statement state = null;
private ResultSet rs = null;
//查询出与些学号对应的全部科目
public ArrayList findByRelationSid(int sid)
{
ArrayList array = new ArrayList();
conn = dao.Tools.getConnection();
try {
state = conn.createStatement();
rs = state.executeQuery("select * from relation where sid ="+sid);
while(rs.next())
{
RelationPO rpo = new RelationPO();
rpo.setCid(rs.getInt("cid"));
rpo.setSid(rs.getInt("sid"));
rpo.setGid(rs.getInt("gid"));
rpo.setExamflag(rs.getString("examflag"));
array.add(rpo);
}
} 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 boolean modifyByRelationSid(int sid,int cid)
{
boolean isok = false;
conn = dao.Tools.getConnection();
try {
state = conn.createStatement();
int i = state.executeUpdate("update relation set examflag = 'YES' where sid = "+sid +"and cid ="+cid);
if(i > 0)
{
isok = true;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if(state != null)
state.close();
if(conn != null)
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return isok;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -