最代码-JSON
2014-12-05 00:20:04
Struts2+Hibernate开发学生成绩后台管理系统
这个项目是利用Struts2+Hibernate实现的一个简单的学生以及学生成绩管理系统,基本上都是CRUD,以及登陆功能。拿来练练手确实是一个相当不错的Demo实例。数据库采用的MySQL数据库,为了方便牛友,提供了相应的数据库,其实有hibernate的话可以反向生成数据库的。登陆名:081101,口令:123
package chao.daoimp;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import chao.dao.CjDao;
import chao.model.Cjb;
import chao.util.HibernateSessionFactory;
public class CjDaoImp implements CjDao {
public Cjb getXsCj(String xh,String kch)
{
Cjb cj=null;
Session session = null;
try {
session=HibernateSessionFactory.getSession();
Query query=session.createQuery("from Cjb where id.xsb.xh='"+xh+"'"+"and id.kcb.kch='"+kch+"'");
cj=(Cjb) query.uniqueResult();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
finally{
session.close();
}
return cj;
}
//根据学号查出学生的姓名及所有课程的课程号、课程名、所获成绩和学分
public List getKcCjList(String kch)
{
List list=null;
Session session=null;
try {
session=HibernateSessionFactory.getSession();
Query query=session.createQuery("from Cjb where id.kcb.kch='"+kch+"'");
list=query.list();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
finally{
session.close();
}
return list;
}
public List getXsCjList(String xh)
{
List list=null;
Session session=null;
try {
session=HibernateSessionFactory.getSession();
Query query=session.createQuery("from Cjb where id.xsb.xh='"+xh+"'");
list=query.list();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
finally{
session.close();
}
return list;
}
//查出所有成绩的学生的学号、姓名、获得学分及对应课程号和课程名
public List findAllCj(int pageNow, int pageSize)
{
List list=null;
Session session=null;
try {
session=HibernateSessionFactory.getSession();
Query query=session.createQuery("from Cjb");
int firstResult = (pageNow - 1) * pageSize;
query.setFirstResult(firstResult);
query.setMaxResults(pageSize);
list=query.list();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
finally{
session.close();
}
return list;
}
public int findCjSize() {
int size=0;
Session session=null;
try {
session=HibernateSessionFactory.getSession();
Query query=session.createQuery("from Cjb");
List list=query.list();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
finally{
session.close();
}
return size;
}
public void deleteCj(String xh,String kch)
{
Session session=null;
try {
session=HibernateSessionFactory.getSession();
Transaction ts = session.beginTransaction();
Query query=session.createQuery("from Cjb where id.xsb.xh='"+xh+"'"+"and id.kcb.kch='"+kch+"'");
Cjb cj=(Cjb) query.uniqueResult();
session.delete(cj);
ts.commit();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
finally{
session.close();
}
}
//删除所有符合课程号的学生成绩
public void deleteOneKcInfo(String kch)
{
Session session=null;
try {
session=HibernateSessionFactory.getSession();
Transaction ts = session.beginTransaction();
session.delete(getKcCjList(kch));
ts.commit();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
finally{
session.close();
}
}
//删除所有符合学号的学生成绩
public void deleteOneXsCj(String xh)
{
Session session=null;
try {
session=HibernateSessionFactory.getSession();
Transaction ts = session.beginTransaction();
session.delete(getXsCjList(xh));
ts.commit();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
finally{
session.close();
}
}
public void save(Cjb cj)
{
Session session=null;
try {
session=HibernateSessionFactory.getSession();
Transaction ts = session.beginTransaction();
session.save(cj);
ts.commit();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
finally{
session.close();
}
}
public void update(Cjb cj)
{
Session session=null;
try {
session=HibernateSessionFactory.getSession();
Transaction ts = session.beginTransaction();
session.update(cj);
ts.commit();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
finally{
session.close();
}
}
}
猜你喜欢
- s2sh开发java web学生成绩管理系统myeclipse+mysql
- s2sh(struts2+spring+hibernate)框架开发java学校教务后台管理系统
- s2sh开发的网页通讯录后台管理项目,学习用的
- 基于s2sh框架和easyui前台的停车信息后台管理系统
- spring+struts2+Hibernate三大框架开发某制药厂管理系统源代码下载
- s2sh(struts2+spring+hibernate)框架搭建人力资源网站后台管理系统
- S2SH(struts2+spring+hibernate)框架实现猫狗宠物后台管理系统,数据查询用json返回数据
- Struts2+Hibernate新闻发布后台管理系统源代码下载
- Struts2+Hibernate3开发实现房屋出租出售后台管理系统,类似于赶驴网
- ssh(hibernate+struts+spring)框架实现简单新闻发布系统
- S2SH(spring+struts2+hibernate) 开发java学生信息管理网站源码下载
- S2SH开发学生选课系统
请下载代码后再发表评论
文件名:student.zip,文件大小:10508.116K
下载
- /
- /student
- /student/xscj_chao
- /student/xscj_chao/.classpath
- /student/xscj_chao/.myeclipse
- /student/xscj_chao/.myhibernatedata
- /student/xscj_chao/.mymetadata
- /student/xscj_chao/.project
- /student/xscj_chao/.settings
- /student/xscj_chao/.settings/.jsdtscope
- /student/xscj_chao/.settings/com.genuitec.eclipse.j2eedt.core.prefs
- /student/xscj_chao/src
- /student/xscj_chao/src/chao
- /student/xscj_chao/src/chao/action
- /student/xscj_chao/src/chao/dao
- /student/xscj_chao/src/chao
- /student/xscj_chao
- /student
相关代码
- spring,struts2,hibernate框架整合
- 证精 S2SH(spring + struts2 + hibernate)整合开发java web进销存后台管理系统,前端extjs
- 原精 S2SH(spring+struts2+hibernate)整合开发java web人事后台管理系统
- 寻求高质量S2SH的项目,具有标准的优化配置书写格式,用于提高学习。
- s2sh全注解实现的增删改查
- S2SH框架开发的简单demo实例
- struts2+hibernate+Spring后台表格分页(easyui)
- s2sh权限管理实例
- 原证 s2sh+jsp开发电影票预订网站,支持mysql和sql server数据库
- 精 Spring+Struts2+Hibernate三大框架开发电子商务门户企业网站源代码下载
- 原 s2sh(Spring4&Struts2.3&Hibernate4)项目整合简单实例
- 证精 s2sh开发的java web开源电子商城系统,包括后台管理系统
最近下载
微信网友_7407113009926144 LV1
3月3日
571818771 LV3
2024年12月16日
fesfefe LV13
2023年9月26日
15116483404 LV2
2021年12月13日
云脏111111 LV2
2021年5月15日
tx1121 LV14
2021年5月6日
admin_z LV22
2021年5月1日
and123456 LV11
2021年4月10日
pierce LV12
2021年3月11日
862960632 LV14
2020年7月7日
最近浏览
微信网友_7407113009926144 LV1
3月3日
571818771 LV3
2024年12月16日
颜菜菜 LV2
2024年6月19日
WBelong LV8
2023年12月25日
卢本伟不开挂 LV4
2023年10月22日
fesfefe LV13
2023年9月26日
wbx666 LV1
2023年9月18日
zhanglm119 LV3
2023年8月30日
sandihha LV9
2023年4月24日
upup996 LV6
2022年12月15日




