做个简单的Java学生考勤系统05--查询课程课表学生与老师信息
Posted exodus3
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了做个简单的Java学生考勤系统05--查询课程课表学生与老师信息相关的知识,希望对你有一定的参考价值。
接下来是完成以下几个功能,主要查询课程信息,课表信息,学生信息与老师信息。
1、查询课表信息
public static Tkebiao get_kebiao(int id)
{
Tkebiao kebiao=new Tkebiao();
String sql="select * from t_kebiao where id=?";
Object[] params={id};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
kebiao.setId(rs.getInt("id"));
kebiao.setKecheng_id(rs.getInt("kecheng_id"));
kebiao.setShijian(rs.getString("shijian"));
kebiao.setJiaoshi(rs.getString("jiaoshi"));
kebiao.setLaoshi_id(rs.getString("laoshi_id"));
kebiao.setKecheng(utilService.get_kecheng(rs.getInt("kecheng_id")));
kebiao.setLaoshi(utilService.get_laoshi(rs.getInt("laoshi_id")));
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
return kebiao;
}
方法讲解:
传入课表id,查询课表相关信息,里面有课程id和老师id,根据这两个id,查询课程信息和老师信息,并填充课程和老师的信息
2、查询所有的课表
public static List get_kebiao_all()
{
List kebiaoList=new ArrayList();
String sql="select * from t_kebiao";
Object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
Tkebiao kebiao=new Tkebiao();
kebiao.setId(rs.getInt("id"));
kebiao.setKecheng_id(rs.getInt("kecheng_id"));
kebiao.setShijian(rs.getString("shijian"));
kebiao.setJiaoshi(rs.getString("jiaoshi"));
kebiao.setLaoshi_id(rs.getString("laoshi_id"));
kebiao.setKecheng(utilService.get_kecheng(rs.getInt("kecheng_id")));
kebiao.setLaoshi(utilService.get_laoshi(rs.getInt("laoshi_id")));
kebiaoList.add(kebiao);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
return kebiaoList;
}
方法讲解:
把所有的课表信息查询出来,跟上面的方法相辅相成,这里把所有的课表信息查询出来,那么我想查询其中一个课表信息,就可以调用上面的方法了
3、查询课程信息
public static Tkecheng get_kecheng(int id)
{
Tkecheng kecheng=new Tkecheng();
String sql="select * from t_kecheng where del='no' and id=?";
Object[] params={id};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
kecheng.setId(rs.getInt("id"));
kecheng.setBianhao(rs.getString("bianhao"));
kecheng.setMingcheng(rs.getString("mingcheng"));
kecheng.setKeshi(rs.getString("keshi"));
kecheng.setDel(rs.getString("del"));
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
return kecheng;
}
根据课程id查询所有的课程信息
4、查询所有的老师信息
public static Tlaoshi get_laoshi(int id)
{
Tlaoshi laoshi=new Tlaoshi();
String sql="select * from t_laoshi where del='no' and id=?";
Object[] params={id};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
laoshi.setId(rs.getInt("id"));
laoshi.setBianhao(rs.getString("bianhao"));
laoshi.setXingming(rs.getString("xingming"));
laoshi.setXingbie(rs.getString("xingbie"));
laoshi.setNianling(rs.getString("nianling"));
laoshi.setZhicheng(rs.getString("zhicheng"));
laoshi.setLoginname(rs.getString("loginname"));
laoshi.setLoginpw(rs.getString("loginpw"));
laoshi.setDel(rs.getString("del"));
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
return laoshi;
}
根据老师id查询所有的老师信息
5、查询所有的学生信息
public static Txuesheng get_xuesheng(int id)
{
Txuesheng xuesheng=new Txuesheng();
String sql="select * from t_xuesheng where id=?";
Object[] params={id};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
xuesheng.setId(rs.getInt("id"));
xuesheng.setXuehao(rs.getString("xuehao"));
xuesheng.setXingming(rs.getString("xingming"));
xuesheng.setXingbie(rs.getString("xingbie"));
xuesheng.setNianling(rs.getString("nianling"));
xuesheng.setBanji(rs.getString("banji"));
xuesheng.setLoginname(rs.getString("loginname"));
xuesheng.setLoginpw(rs.getString("loginpw"));
xuesheng.setDel(rs.getString("del"));
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
return xuesheng;
}
根据学生id查询所有的学生信息
现在主要的课程,课表,学生,老师,以及考勤的相关的信息的查询功能都已经完成了,接下来就是对这个系统的拓展了。
以上是关于做个简单的Java学生考勤系统05--查询课程课表学生与老师信息的主要内容,如果未能解决你的问题,请参考以下文章