精华内容
下载资源
问答
  • 2021-04-22 11:14:11

    按照网上的教程和素材制作,第一部分信息管理

    1c0cf8992cfe358ed07cab20c190e521.png

    6f23c7596e525d84e26632853e40acde.png

    源码

    ackage com.ischoolbar.programmer.dao;

    import java.sql.ResultSet;

    import java.sql.SQLException;

    import com.ischoolbar.programmer.model.Admin;

    import com.ischoolbar.programmer.model.Clazz;

    /**

    *

    * @author llq

    *管理员数据库操作封装

    */

    public class AdminDao extends BaseDao {

    public Admin login(String name ,String password){

    String sql = "select * from s_admin where name = '" + name + "' and password = '" + password + "'";

    ResultSet resultSet = query(sql);

    try {

    if(resultSet.next()){

    Admin admin = new Admin();

    admin.setId(resultSet.getInt("id"));

    admin.setName(resultSet.getString("name"));

    admin.setPassword(resultSet.getString("password"));

    admin.setStatus(resultSet.getInt("status"));

    return admin;

    }

    } catch (SQLException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    }

    return null;

    }

    public boolean editPassword(Admin admin,String newPassword) {

    // TODO Auto-generated method stub

    String sql = "update s_admin set password = '"+newPassword+"' where id = " + admin.getId();

    return update(sql);

    }

    }

    package com.ischoolbar.programmer.dao;

    import java.sql.Connection;

    import java.sql.PreparedStatement;

    import java.sql.ResultSet;

    import java.sql.SQLException;

    import java.util.ArrayList;

    import java.util.List;

    import com.ischoolbar.programmer.util.DbUtil;

    /**

    *

    * @author llq

    *基础dao,封装基本操作

    */

    public class BaseDao {

    private DbUtil dbUtil = new DbUtil();

    /**

    * 关闭数据库连接,释放资源

    */

    public void closeCon(){

    dbUtil.closeCon();

    }

    /**

    * 基础查询,多条查询

    */

    public ResultSet query(String sql){

    try {

    PreparedStatement prepareStatement = dbUtil.getConnection().prepareStatement(sql);

    return prepareStatement.executeQuery();

    } catch (SQLException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    }

    return null;

    }

    /**

    *改变数据库内容操作

    */

    public boolean update(String sql){

    try {

    return dbUtil.getConnection().prepareStatement(sql).executeUpdate() > 0;

    } catch (SQLException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    }

    return false;

    }

    public Connection getConnection(){

    return dbUtil.getConnection();

    }

    }

    package com.ischoolbar.programmer.dao;

    import java.sql.Connection;

    import java.sql.PreparedStatement;

    import java.sql.ResultSet;

    import java.sql.SQLException;

    import java.util.ArrayList;

    import java.util.List;

    import com.ischoolbar.programmer.model.Admin;

    import com.ischoolbar.programmer.model.Clazz;

    import com.ischoolbar.programmer.model.Page;

    import com.ischoolbar.programmer.model.Student;

    import com.ischoolbar.programmer.util.StringUtil;

    public class StudentDao extends BaseDao {

    public boolean addStudent(Student student){

    String sql = "insert into s_student values(null,'"+student.getSn()+"','"+student.getName()+"'";

    sql += ",'" + student.getPassword() + "'," + student.getClazzId();

    sql += ",'" + student.getSex() + "','" + student.getMobile() + "'";

    sql += ",'" + student.getQq() + "',null)";

    return update(sql);

    }

    public boolean editStudent(Student student) {

    // TODO Auto-generated method stub

    String sql = "update s_student set name = '"+student.getName()+"'";

    sql += ",sex = '" + student.getSex() + "'";

    sql += ",mobile = '" + student.getMobile() + "'";

    sql += ",qq = '" + student.getQq() + "'";

    sql += ",clazz_id = " + student.getClazzId();

    sql += " where id = " + student.getId();

    return update(sql);

    }

    public boolean setStudentPhoto(Student student) {

    // TODO Auto-generated method stub

    String sql = "update s_student set photo = ? where id = ?";

    Connection connection = getConnection();

    try {

    PreparedStatement prepareStatement = connection.prepareStatement(sql);

    prepareStatement.setBinaryStream(1, student.getPhoto());

    prepareStatement.setInt(2, student.getId());

    return prepareStatement.executeUpdate() > 0;

    } catch (SQLException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    }

    return update(sql);

    }

    public boolean deleteStudent(String ids) {

    // TODO Auto-generated method stub

    String sql = "delete from s_student where id in("+ids+")";

    return update(sql);

    }

    public Student getStudent(int id){

    String sql = "select * from s_student where id = " + id;

    Student student = null;

    ResultSet resultSet = query(sql);

    try {

    if(resultSet.next()){

    student = new Student();

    student.setId(resultSet.getInt("id"));

    student.setClazzId(resultSet.getInt("clazz_id"));

    student.setMobile(resultSet.getString("mobile"));

    student.setName(resultSet.getString("name"));

    student.setPassword(resultSet.getString("password"));

    student.setPhoto(resultSet.getBinaryStream("photo"));

    student.setQq(resultSet.getString("qq"));

    student.setSex(resultSet.getString("sex"));

    student.setSn(resultSet.getString("sn"));

    return student;

    }

    } catch (SQLException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    }

    return student;

    }

    public List getStudentList(Student student,Page page){

    List ret = new ArrayList();

    String sql = "select * from s_student ";

    if(!StringUtil.isEmpty(student.getName())){

    sql += "and name like '%" + student.getName() + "%'";

    }

    if(student.getClazzId() != 0){

    sql += " and clazz_id = " + student.getClazzId();

    }

    if(student.getId() != 0){

    sql += " and id = " + student.getId();

    }

    sql += " limit " + page.getStart() + "," + page.getPageSize();

    ResultSet resultSet = query(sql.replaceFirst("and", "where"));

    try {

    while(resultSet.next()){

    Student s = new Student();

    s.setId(resultSet.getInt("id"));

    s.setClazzId(resultSet.getInt("clazz_id"));

    s.setMobile(resultSet.getString("mobile"));

    s.setName(resultSet.getString("name"));

    s.setPassword(resultSet.getString("password"));

    s.setPhoto(resultSet.getBinaryStream("photo"));

    s.setQq(resultSet.getString("qq"));

    s.setSex(resultSet.getString("sex"));

    s.setSn(resultSet.getString("sn"));

    ret.add(s);

    }

    } catch (SQLException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    }

    return ret;

    }

    public int getStudentListTotal(Student student){

    int total = 0;

    String sql = "select count(*)as total from s_student ";

    if(!StringUtil.isEmpty(student.getName())){

    sql += "and name like '%" + student.getName() + "%'";

    }

    if(student.getClazzId() != 0){

    sql += " and clazz_id = " + student.getClazzId();

    }

    if(student.getId() != 0){

    sql += " and id = " + student.getId();

    }

    ResultSet resultSet = query(sql.replaceFirst("and", "where"));

    try {

    while(resultSet.next()){

    total = resultSet.getInt("total");

    }

    } catch (SQLException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    }

    return total;

    }

    package com.ischoolbar.programmer.util;

    import java.sql.Connection;

    import java.sql.Driver;

    import java.sql.DriverManager;

    import java.sql.SQLException;

    import javax.management.loading.PrivateClassLoader;

    /**

    *

    * @author llq

    *数据库连util

    */

    public class DbUtil {

    private String dbUrl = "jdbc:mysql://localhost:3306/db_student_manager_web?useUnicode=true&characterEncoding=utf8";

    private String dbUser = "root";

    private String dbPassword = "";

    private String jdbcName = "com.mysql.jdbc.Driver";

    private Connection connection = null;

    public Connection getConnection(){

    try {

    Class.forName(jdbcName);

    connection = DriverManager.getConnection(dbUrl, dbUser, dbPassword);

    System.out.println("数据库链接成功!");

    } catch (Exception e) {

    // TODO Auto-generated catch block

    System.out.println("数据库链接失败!");

    e.printStackTrace();

    }

    return connection;

    }

    public void closeCon(){

    if(connection != null)

    try {

    connection.close();

    System.out.println("数据库链接已关闭!");

    } catch (SQLException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    }

    }

    public static void main(String[] args) {

    // TODO Auto-generated method stub

    DbUtil dbUtil = new DbUtil();

    dbUtil.getConnection();

    }

    }

    标签:JAVAWEB,选课,系统,resultSet,student,sql,import,public,String

    来源: https://www.cnblogs.com/ICDTAD/p/12152648.html

    更多相关内容
  • javaweb选课系统

    2018-02-28 13:24:03
    javaweb选课系统,ssm框架 javaweb选课系统,ssm框架 javaweb选课系统,ssm框架
  • 本课程演示的是一套基于JavaWeb实现的学生选课系统,主要针对计算机相关专业的正在做毕设的学生与需要项目实战练习的java人群。 包含:项目源码、项目文档、数据库脚本、软件工具等,该项目附带全部源码可作为毕设...
  • javaweb高校学生选课系统项目源码.zip
  • 学生:注册登录,修改信息,查看选课信息,查看成绩,查看公告,课程信息管理 教师:登录注册,课程信息,查看学生选课情况,成绩管理(对学生成绩增删改查),修改密码,查看公告 管理员:学生,教师班级,课程信息...
  • 对于高校学生选课系统来说,针对的用户一般为学生,所以根据用户的需求,要求高校学生选课系统界面设计美观大方、操作简捷灵活,同时在该系统中用户要求必须实现课程信息的具体管理,学生查看历史选课情况,学生注册...
  • 采用eclipse和MySQL开发的学生在线选课系统。功能如下: ...这个是我的JavaWeb课程设计作业,由于能力有限,这个系统的一些细节还不够完善,比如没有密码加密和分页,页面不够美观,以后会完善的。
  • (1)系统的外部角色有:学生用户、教师用户和管理员。 (2)系统主要用例的文档描述: ①学生管理用例:学生用户可见的功能,包含了选课、退课和查看选课三个用例功能。 ②教师管理用例:教师用户可见的功能,包含...
  • 简单的JAVAWeb选课系统

    2021-03-05 20:55:53
    系统管理员可以添加和删除学生、教师,教师可以修改自己信息、添加课程、浏览自己课程,学生可以修改自己的信息、选课、浏览全部课程。首先展示文件:然后就是一次展示代码:Guanli包中代码:package Guanli;...

    该系统管理员可以添加和删除学生、教师,教师可以修改自己信息、添加课程、浏览自己课程,学生可以修改自己的信息、选课、浏览全部课程。

    首先展示文件:

    d83204266a1e84646ee3a5f71a3cfc15.png

    d1c0233b78e4348a6c40389ef903b28b.png

    a8bf7530eef63499770b436ef7dda29d.png

    然后就是一次展示代码:

    Guanli包中代码:

    package Guanli;

    import java.sql.Connection;

    import java.sql.SQLException;

    import java.sql.Statement;

    import Login.DBUtil;public classAdd {publicboolean add(String table,AddService en)

    {

    boolean c=false;

    String sql="insert into"+table+"(username,password,power,name) values('"+en.getUsername()+"','"+en.getPassword()+"','"+en.getPower()+"','"+en.getName()+"');";

    Connection conn=DBUtil.getConn();

    Statement state=null;try{

    state=conn.createStatement();int num=state.executeUpdate(sql);if(num!=0)

    c=true;

    state.close();

    conn.close();

    }catch(SQLException e) {//TODO Auto-generated catch block//e.printStackTrace();

    }returnc;

    }publicboolean add(String table,TeacherService en)

    {

    boolean c=false;

    String sql="insert into"+table+"(gonghao,xingming,xingbie,xueyuan,zhicheng) values('"+en.getGonghao()+"','"+en.getXingming()+"','"+en.getXingbie()+"','"+en.getXueyuan()+"','"+en.getZhicheng()+"');";

    Connection conn=DBUtil.getConn();

    Statement state=null;try{

    state=conn.createStatement();int num=state.executeUpdate(sql);if(num!=0)

    c=true;

    state.close();

    conn.close();

    }catch(SQLException e) {//TODO Auto-generated catch block//e.printStackTrace();

    }returnc;

    }publicboolean add(String table,StudentService en)

    {

    boolean c=false;

    String sql="insert into"+table+"(xuehao,xingming,xingbie,banji,zhuanye) values('"+en.getXuehao()+"','"+en.getXingming()+"','"+en.getXingbie()+"','"+en.getBanji()+"','"+en.getZhuanye()+"');";

    Connection conn=DBUtil.getConn();

    Statement state=null;try{

    state=conn.createStatement();int num=state.executeUpdate(sql);if(num!=0)

    c=true;

    state.close();

    conn.close();

    }catch(SQLException e) {//TODO Auto-generated catch block//e.printStackTrace();

    }returnc;

    }

    }

    package Guanli;

    import java.sql.Time;

    import java.text.SimpleDateFormat;

    import java.util.Date;public classAddService {

    String username;

    String password;

    String name;publicString getName() {returnname;

    }public voidsetName(String name) {this.name =name;

    }intpower;publicString getUsername() {returnusername;

    }public voidsetUsername(String username) {this.username =username;

    }publicString getPassword() {returnpassword;

    }public voidsetPassword(String password) {this.password =password;

    }public intgetPower() {returnpower;

    }public void setPower(intpower) {this.power =power;

    }

    }

    packageGuanli;importjava.awt.Desktop.Action;importjava.io.IOException;importjavax.servlet.ServletException;importjavax.servlet.annotation.WebServlet;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importLogin.Power;importLogin.Select;/*** Servlet implementation class RegisterServlet*/@WebServlet("/RegisterServlet")public class RegisterServlet extendsHttpServlet {private static final long serialVersionUID = 1L;/***@seeHttpServlet#HttpServlet()*/

    publicRegisterServlet() {super();//TODO Auto-generated constructor stub

    }protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throwsServletException, IOException

    {

    Select s=newSelect();

    arg0.setCharacterEncoding("utf-8");

    arg1.setCharacterEncoding("utf-8");booleanflag;

    String function=arg0.getParameter("method");if(function.equals("teacher"))

    {

    AddService as=newAddService();

    Add a=newAdd();

    String username;

    username=arg0.getParameter("username");

    as.setUsername(username);

    String password;

    password=arg0.getParameter("password");

    as.setPassword(password);int num=1;

    as.setPower(num);

    TeacherService ts=newTeacherService();

    String gonghao;

    gonghao=arg0.getParameter("gonghao");

    ts.setGonghao(gonghao);

    String xingming;

    xingming=arg0.getParameter("xingming");

    ts.setXingming(xingming);

    as.setName(xingming);

    String xingbie;

    xingbie=arg0.getParameter("xingbie");

    ts.setXingbie(xingbie);

    String xueyuan;

    xueyuan=arg0.getParameter("xueyuan");

    ts.setXueyuan(xueyuan);

    String zhicheng;

    zhicheng=arg0.getParameter("zhicheng");

    ts.setZhicheng(zhicheng);

    a.add("login", as);

    a.add("teacher", ts);

    arg0.setAttribute("message","添加成功");

    arg0.getRequestDispatcher("Right.jsp").forward(arg0, arg1);

    }if(function.equals("student"))

    {

    AddService as=newAddService();

    Add a=newAdd();

    String username;

    username=arg0.getParameter("username");

    as.setUsername(username);

    String password;

    password=arg0.getParameter("password");

    as.setPassword(password);int num=2;

    as.setPower(num);

    StudentService ss=newStudentService();

    String xuehao;

    xuehao=arg0.getParameter("xuehao");

    ss.setXuehao(xuehao);

    String xingming;

    xingming=arg0.getParameter("xingming");

    ss.setXingming(xingming);

    as.setName(xingming);

    String xingbie;

    xingbie=arg0.getParameter("xingbie");

    ss.setXingbie(xingbie);

    String banji;

    banji=arg0.getParameter("banji");

    ss.setBanji(banji);

    String zhuanye;

    zhuanye=arg0.getParameter("zhuanye");

    ss.setZhuanye(zhuanye);

    a.add("student", ss);

    a.add("login", as);

    arg0.setAttribute("message","添加成功");

    arg0.getRequestDispatcher("Right.jsp").forward(arg0, arg1);

    }

    }/***@seeHttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)*/

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {//TODO Auto-generated method stub

    response.getWriter().append("Served at: ").append(request.getContextPath());

    }/***@seeHttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)*/

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {//TODO Auto-generated method stub

    doGet(request, response);

    }

    }

    packageGuanli;public classStudentService {

    String xuehao;

    String xingming;

    String xingbie;

    String banji;

    String zhuanye;publicString getXuehao() {returnxuehao;

    }public voidsetXuehao(String xuehao) {this.xuehao =xuehao;

    }publicString getXingming() {returnxingming;

    }public voidsetXingming(String xingming) {this.xingming =xingming;

    }publicString getXingbie() {returnxingbie;

    }public voidsetXingbie(String xingbie) {this.xingbie =xingbie;

    }publicString getBanji() {returnbanji;

    }public voidsetBanji(String banji) {this.banji =banji;

    }publicString getZhuanye() {returnzhuanye;

    }public voidsetZhuanye(String zhuanye) {this.zhuanye =zhuanye;

    }

    }

    packageGuanli;public classTeacherService {

    String gonghao;

    String xingming;

    String xingbie;

    String xueyuan;

    String zhicheng;publicString getGonghao() {returngonghao;

    }public voidsetGonghao(String gonghao) {this.gonghao =gonghao;

    }publicString getXingming() {returnxingming;

    }public voidsetXingming(String xingming) {this.xingming =xingming;

    }publicString getXingbie() {returnxingbie;

    }public voidsetXingbie(String xingbie) {this.xingbie =xingbie;

    }publicString getXueyuan() {returnxueyuan;

    }public voidsetXueyuan(String xueyuan) {this.xueyuan =xueyuan;

    }publicString getZhicheng() {returnzhicheng;

    }public voidsetZhicheng(String zhicheng) {this.zhicheng =zhicheng;

    }

    }

    Login包里的文件:

    packageLogin;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.PreparedStatement;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;/*** 数据库连接工具

    *@authorHu

    **/

    public classDBUtil {public static String db_url = "jdbc:mysql://localhost:3306/jianmintest?useSSL=false&serverTimezone=UTC&characterEncoding=UTF-8";public static String db_user = "root";public static String db_pass = "20183629";public staticConnection getConn () {

    Connection conn= null;try{

    Class.forName("com.mysql.jdbc.Driver");//加载驱动

    conn =DriverManager.getConnection(db_url, db_user, db_pass);

    }catch(Exception e) {

    e.printStackTrace();

    }returnconn;

    }/*** 关闭连接

    *@paramstate

    *@paramconn*/

    public static voidclose (Statement state, Connection conn) {if (state != null) {try{

    state.close();

    }catch(SQLException e) {

    e.printStackTrace();

    }

    }if (conn != null) {try{

    conn.close();

    }catch(SQLException e) {

    e.printStackTrace();

    }

    }

    }public static voidclose (ResultSet rs, Statement state, Connection conn) {if (rs != null) {try{

    rs.close();

    }catch(SQLException e) {

    e.printStackTrace();

    }

    }if (state != null) {try{

    state.close();

    }catch(SQLException e) {

    e.printStackTrace();

    }

    }if (conn != null) {try{

    conn.close();

    }catch(SQLException e) {

    e.printStackTrace();

    }

    }

    }public static void main(String[] args) throwsSQLException {

    Connection conn=getConn();

    PreparedStatement pstmt= null;

    ResultSet rs= null;

    String sql="select * from course";

    pstmt=conn.prepareStatement(sql);

    rs=pstmt.executeQuery();if(rs.next()){

    System.out.println("空");

    }else{

    System.out.println("不空");

    }

    }

    }

    packageLogin;importjava.io.IOException;importjavax.servlet.ServletException;importjavax.servlet.annotation.WebServlet;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;/*** Servlet implementation class LoginServlet*/@WebServlet("/LoginServlet")public class LoginServlet extendsHttpServlet {private static final long serialVersionUID = 1L;/***@seeHttpServlet#HttpServlet()*/

    publicLoginServlet() {super();//TODO Auto-generated constructor stub

    }protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throwsServletException, IOException

    {

    Select s=newSelect();

    arg0.setCharacterEncoding("utf-8");

    arg1.setCharacterEncoding("utf-8");booleanflag;

    String function=arg0.getParameter("method");if(function.equals("login"))

    {

    String username;

    username=arg0.getParameter("username");

    String password;

    password=arg0.getParameter("password");

    String power;

    power=arg0.getParameter("power");int num=Integer.parseInt(power);

    flag=s.select("login", username, password,num);

    Power.setFlag(num);if(flag)

    {

    arg0.setAttribute("message","登录成功");

    arg0.getRequestDispatcher("Home.jsp").forward(arg0, arg1);

    }else{

    arg0.setAttribute("message", "账号或密码有误");

    arg0.getRequestDispatcher("Login.jsp").forward(arg0, arg1);

    }

    }

    }/***@seeHttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)*/

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {//TODO Auto-generated method stub

    response.getWriter().append("Served at: ").append(request.getContextPath());

    }/***@seeHttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)*/

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {//TODO Auto-generated method stub

    doGet(request, response);

    }

    }

    packageLogin;public classPower {static intflag;public static intgetFlag() {returnflag;

    }public static void setFlag(intflag) {

    Power.flag=flag;

    }staticString xingming;public staticString getXingming() {returnxingming;

    }public static voidsetXingming(String xingming) {

    Power.xingming=xingming;

    }staticString username;public staticString getUsername() {returnusername;

    }public static voidsetUsername(String username) {

    Power.username=username;

    }

    }

    packageLogin;importjava.sql.Connection;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;public classSelect {public boolean select(String table,String username,String password,intnum)

    {boolean f=false;

    Connection conn=DBUtil.getConn();

    Statement state=null;try{

    state=conn.createStatement();

    String sql="select * from "+table;

    ResultSet rs=state.executeQuery(sql);while(rs.next())

    {if(username.equals(rs.getString(1))&&password.equals(rs.getString(2))&&rs.getInt(4)==num)

    {

    Power.setXingming(rs.getString(3));

    Power.setUsername(rs.getString(1));

    System.out.println(Power.getXingming());

    f=true;

    }

    }

    rs.close();

    state.close();

    conn.close();

    }catch(Exception e)

    {

    }returnf;

    }

    }

    Student包中的代码:

    packageStudent;importjava.sql.Connection;importjava.sql.SQLException;importjava.sql.Statement;importLogin.DBUtil;public classAdd {public booleanadd(String table,Jieguo en)

    {boolean c=false;

    String sql="insert into "+table+"(kechengbianhao,gonghao,jiaoshixingming,xuehao,xingming) values('"+en.getKechengbianhao()+"','"+en.getGonghao()+"','"+en.getJiaoshixingming()+"','"+en.getXuehao()+"','"+en.getXingming()+"');";

    System.out.println(sql);

    Connection conn=DBUtil.getConn();

    Statement state=null;try{

    state=conn.createStatement();int num=state.executeUpdate(sql);if(num!=0)

    c=true;

    state.close();

    conn.close();

    }catch(SQLException e) {//TODO Auto-generated catch block//e.printStackTrace();

    }returnc;

    }

    }

    packageStudent;importjava.sql.Connection;importjava.sql.SQLException;importjava.sql.Statement;importLogin.DBUtil;public classChange {public booleanchange(String table,String lie,String lie0,String gai,String biao)

    {

    Connection conn=DBUtil.getConn();

    Statement state=null;try{

    state=conn.createStatement();

    String sql="update "+table+" set "+lie+"='"+gai+"' where "+lie0+"='"+biao+"'";

    System.out.println(sql);

    state.executeUpdate(sql);

    state.close();

    conn.close();

    }catch(SQLException e) {//TODO Auto-generated catch block

    e.printStackTrace();

    }return true;

    }

    }

    packageStudent;importjava.sql.Connection;importjava.sql.ResultSet;importjava.sql.Statement;importLogin.DBUtil;public classFind {public booleanfind(String table,String id)

    {booleanc;

    Connection conn=DBUtil.getConn();

    Statement state=null;try{

    state=conn.createStatement();

    String sql="select * from "+table+" where xingming ='"+id+"'";

    ResultSet rs=state.executeQuery(sql);while(rs.next())

    {

    Service.setXuehao(rs.getString(1));

    Service.setXingming(rs.getString(2));

    Service.setXingbie(rs.getString(3));

    Service.setBanji(rs.getString(4));

    Service.setZhuanye(rs.getString(5));

    }

    rs.close();

    state.close();

    conn.close();

    System.out.println("over");

    }catch(Exception e)

    {

    }return true;

    }public voidfindclass(String table,String id)

    {booleanc;

    Connection conn=DBUtil.getConn();

    Statement state=null;try{

    state=conn.createStatement();

    String sql="select * from "+table+" where kechengbianhao ='"+id+"'";

    ResultSet rs=state.executeQuery(sql);while(rs.next())

    {

    KechengService.setKechengbianhao(rs.getString(1));

    KechengService.setKechengmingcheng(rs.getString(2));

    KechengService.setRenkejiaoshi(rs.getString(4));

    KechengService.setRenshushangxian(rs.getInt(5));

    KechengService.setXianyourenshu(rs.getInt(6));

    }

    rs.close();

    state.close();

    conn.close();

    System.out.println("over");

    }catch(Exception e)

    {

    }

    }public voidfindjiaoshi(String table,String id)

    {booleanc;

    Connection conn=DBUtil.getConn();

    Statement state=null;try{

    state=conn.createStatement();

    String sql="select * from "+table+" where gonghao ='"+id+"'";

    ResultSet rs=state.executeQuery(sql);while(rs.next())

    {

    TeacherService.setGonghao(rs.getString(1));

    TeacherService.setXingming(rs.getString(2));

    TeacherService.setXingbie(rs.getString(3));

    TeacherService.setXueyuan(rs.getString(4));

    TeacherService.setZhicheng(rs.getString(5));

    }

    rs.close();

    state.close();

    conn.close();

    System.out.println("over");

    }catch(Exception e)

    {

    }

    }

    }

    packageStudent;importjava.sql.Connection;importjava.sql.PreparedStatement;importjava.sql.ResultSet;importjava.util.ArrayList;importjava.util.List;importLogin.DBUtil;importTeacher.KechengService;public classGet {public static ListgetAll()

    {

    List list=new ArrayList();

    Connection conn=DBUtil.getConn();

    PreparedStatement state=null;

    ResultSet rs=null;

    String sql="select * from class";try{

    state=conn.prepareStatement(sql);

    rs=state.executeQuery();while(rs.next())

    {if(rs.getInt(5)>rs.getInt(6))

    {

    KechengService user=newKechengService();

    user.setKechengbianhao(rs.getString(1));

    user.setKechengmingcheng(rs.getString(2));

    user.setGonghao(rs.getString(3));

    user.setRenkejiaoshi(rs.getString(4));

    user.setXianyourenshu(rs.getInt(6));

    list.add(user);

    }

    }

    rs.close();

    state.close();

    conn.close();

    }catch(Exception e)

    {

    }if(list!=null) {returnlist;

    }else{return null;

    }

    }public static ListgetAll0()

    {

    List list=new ArrayList();

    Connection conn=DBUtil.getConn();

    PreparedStatement state=null;

    ResultSet rs=null;

    String sql="select * from class";try{

    state=conn.prepareStatement(sql);

    rs=state.executeQuery();while(rs.next())

    {

    KechengService user=newKechengService();

    user.setKechengbianhao(rs.getString(1));

    user.setKechengmingcheng(rs.getString(2));

    user.setGonghao(rs.getString(3));

    user.setRenkejiaoshi(rs.getString(4));

    user.setXianyourenshu(rs.getInt(6));

    list.add(user);

    }

    rs.close();

    state.close();

    conn.close();

    }catch(Exception e)

    {

    }if(list!=null) {returnlist;

    }else{return null;

    }

    }

    }

    packageStudent;public classJieguo {

    String kechengbianhao;

    String jiaoshixingming;

    String gonghao;

    String xuehao;

    String xingming;publicString getGonghao() {returngonghao;

    }public voidsetGonghao(String gonghao) {this.gonghao =gonghao;

    }publicString getKechengbianhao() {returnkechengbianhao;

    }public voidsetKechengbianhao(String kechengbianhao) {this.kechengbianhao =kechengbianhao;

    }publicString getJiaoshixingming() {returnjiaoshixingming;

    }public voidsetJiaoshixingming(String jiaoshixingming) {this.jiaoshixingming =jiaoshixingming;

    }publicString getXuehao() {returnxuehao;

    }public voidsetXuehao(String xuehao) {this.xuehao =xuehao;

    }publicString getXingming() {returnxingming;

    }public voidsetXingming(String xingming) {this.xingming =xingming;

    }

    }

    packageStudent;public classKechengService {staticString kechengbianhao;staticString kechengmingcheng;staticString renkejiaoshi;static intxianyourenshu;static intrenshushangxian;public static intgetRenshushangxian() {returnrenshushangxian;

    }public static void setRenshushangxian(intrenshushangxian) {

    KechengService.renshushangxian=renshushangxian;

    }public staticString getKechengbianhao() {returnkechengbianhao;

    }public static voidsetKechengbianhao(String kechengbianhao) {

    KechengService.kechengbianhao=kechengbianhao;

    }public staticString getKechengmingcheng() {returnkechengmingcheng;

    }public static voidsetKechengmingcheng(String kechengmingcheng) {

    KechengService.kechengmingcheng=kechengmingcheng;

    }public staticString getRenkejiaoshi() {returnrenkejiaoshi;

    }public static voidsetRenkejiaoshi(String renkejiaoshi) {

    KechengService.renkejiaoshi=renkejiaoshi;

    }public static intgetXianyourenshu() {returnxianyourenshu;

    }public static void setXianyourenshu(intxianyourenshu) {

    KechengService.xianyourenshu=xianyourenshu;

    }

    }

    packageStudent;importjava.io.IOException;importjava.util.List;importjavax.servlet.ServletException;importjavax.servlet.annotation.WebServlet;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importLogin.Power;importTeacher.KechengService;/*** Servlet implementation class LLKEServlet*/@WebServlet("/LLKCServlet")public class LLKCServlet extendsHttpServlet {private static final long serialVersionUID = 1L;/***@seeHttpServlet#HttpServlet()*/

    publicLLKCServlet() {super();//TODO Auto-generated constructor stub

    }protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throwsServletException, IOException

    {

    arg0.setCharacterEncoding("utf-8");

    arg1.setCharacterEncoding("utf-8");booleanflag;

    String function=arg0.getParameter("method");if(function.equals("submit"))

    {

    List userall =Get.getAll0();

    java.util.Collections.reverse(userall);

    arg0.setAttribute("all", userall);

    arg0.getRequestDispatcher("student/liulan.jsp").forward(arg0, arg1);

    }if(function.equals("kecheng"))

    {

    String kechengbianhao=arg0.getParameter("kechengbianhao");

    Find f=newFind();

    f.findclass("class", kechengbianhao);

    arg0.getRequestDispatcher("student/kecheng.jsp").forward(arg0, arg1);

    }if(function.equals("jiaoshi"))

    {

    String gonghao;

    gonghao=arg0.getParameter("gonghao");

    Find f=newFind();

    f.findjiaoshi("teacher", gonghao);

    arg0.getRequestDispatcher("student/jiaoshi.jsp").forward(arg0, arg1);

    }

    }/***@seeHttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)*/

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {//TODO Auto-generated method stub

    response.getWriter().append("Served at: ").append(request.getContextPath());

    }/***@seeHttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)*/

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {//TODO Auto-generated method stub

    doGet(request, response);

    }

    }

    packageStudent;importjava.sql.Connection;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;importLogin.DBUtil;public classSelect {public booleanselect(String table,String kechengbianhao,String xuehao)

    {boolean c=true;

    Connection conn=DBUtil.getConn();

    Statement state=null;try{

    state=conn.createStatement();

    String sql="select * from "+table;

    ResultSet rs=state.executeQuery(sql);while(rs.next())

    {if(kechengbianhao.equals(rs.getString(1))&&xuehao.equals(rs.getString(4)))

    {

    c=false;

    }

    }

    rs.close();

    state.close();

    conn.close();

    }catch(Exception e)

    {

    }returnc;

    }

    }

    packageStudent;public classService {staticString xuehao;staticString xingming;staticString xingbie;staticString banji;staticString zhuanye;public staticString getXuehao() {returnxuehao;

    }public static voidsetXuehao(String xuehao) {

    Service.xuehao=xuehao;

    }public staticString getXingming() {returnxingming;

    }public static voidsetXingming(String xingming) {

    Service.xingming=xingming;

    }public staticString getXingbie() {returnxingbie;

    }public static voidsetXingbie(String xingbie) {

    Service.xingbie=xingbie;

    }public staticString getBanji() {returnbanji;

    }public static voidsetBanji(String banji) {

    Service.banji=banji;

    }public staticString getZhuanye() {returnzhuanye;

    }public static voidsetZhuanye(String zhuanye) {

    Service.zhuanye=zhuanye;

    }

    }

    packageStudent;importjava.io.IOException;importjavax.servlet.ServletException;importjavax.servlet.annotation.WebServlet;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importLogin.Power;/*** Servlet implementation class SXiugaiServlet*/@WebServlet("/SXiugaiServlet")public class SXiugaiServlet extendsHttpServlet {private static final long serialVersionUID = 1L;/***@seeHttpServlet#HttpServlet()*/

    publicSXiugaiServlet() {super();//TODO Auto-generated constructor stub

    }protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throwsServletException, IOException

    {

    arg0.setCharacterEncoding("utf-8");

    arg1.setCharacterEncoding("utf-8");booleanflag;

    String function=arg0.getParameter("method");if(function.equals("submit"))

    {

    Find f=newFind();

    f.find("student", Power.getXingming());

    arg0.getRequestDispatcher("student/xiugaixinxi.jsp").forward(arg0, arg1);

    }if(function.equals("xiugai"))

    {

    Change c=newChange();

    String xingming;

    xingming=arg0.getParameter("xingming");

    String xingbie;

    xingbie=arg0.getParameter("xingbie");

    String banji;

    banji=arg0.getParameter("banji");

    String zhuanye;

    zhuanye=arg0.getParameter("zhuanye");

    c.change("jieguo", "xingming", "xuehao", xingming, Service.getXuehao());

    c.change("login", "name", "username", xingming, Power.getUsername());

    Power.setUsername(xingming);

    c.change("student", "xingming", "xuehao", xingming, Service.getXuehao());

    c.change("student", "xingbie", "xuehao", xingbie, Service.getXuehao());

    c.change("student", "xueyuan", "xuehao", banji, Service.getXuehao());

    c.change("student", "zhicheng", "xuehao", zhuanye, Service.getXuehao());

    arg0.setAttribute("message", "修改成功");

    arg0.getRequestDispatcher("Right.jsp").forward(arg0, arg1);

    }

    }/***@seeHttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)*/

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {//TODO Auto-generated method stub

    response.getWriter().append("Served at: ").append(request.getContextPath());

    }/***@seeHttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)*/

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {//TODO Auto-generated method stub

    doGet(request, response);

    }

    }

    packageStudent;public classTeacherService {staticString gonghao;staticString xingming;staticString xingbie;staticString xueyuan;staticString zhicheng;public staticString getGonghao() {returngonghao;

    }public static voidsetGonghao(String gonghao) {

    TeacherService.gonghao=gonghao;

    }public staticString getXingming() {returnxingming;

    }public static voidsetXingming(String xingming) {

    TeacherService.xingming=xingming;

    }public staticString getXingbie() {returnxingbie;

    }public static voidsetXingbie(String xingbie) {

    TeacherService.xingbie=xingbie;

    }public staticString getXueyuan() {returnxueyuan;

    }public static voidsetXueyuan(String xueyuan) {

    TeacherService.xueyuan=xueyuan;

    }public staticString getZhicheng() {returnzhicheng;

    }public static voidsetZhicheng(String zhicheng) {

    TeacherService.zhicheng=zhicheng;

    }

    }

    packageStudent;importjava.io.IOException;importjava.util.List;importjavax.servlet.ServletException;importjavax.servlet.annotation.WebServlet;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importLogin.Power;importTeacher.KechengService;/*** Servlet implementation class XuankeServlet*/@WebServlet("/XuankeServlet")public class XuankeServlet extendsHttpServlet {private static final long serialVersionUID = 1L;/***@seeHttpServlet#HttpServlet()*/

    publicXuankeServlet() {super();//TODO Auto-generated constructor stub

    }protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throwsServletException, IOException

    {

    arg0.setCharacterEncoding("utf-8");

    arg1.setCharacterEncoding("utf-8");booleanflag;

    String function=arg0.getParameter("method");if(function.equals("submit"))

    {

    List userall =Get.getAll();

    java.util.Collections.reverse(userall);

    arg0.setAttribute("all", userall);

    arg0.getRequestDispatcher("student/xuanke.jsp").forward(arg0, arg1);

    }if(function.equals("xuanke"))

    {

    Change c=newChange();

    Jieguo j=newJieguo();

    Find f=newFind();

    f.find("student", Power.getXingming());

    String jiaoshixingming;

    jiaoshixingming=arg0.getParameter("jiaoshixingming");

    j.setJiaoshixingming(jiaoshixingming);

    String kechengbianhao;

    kechengbianhao=arg0.getParameter("kechengbianhao");

    j.setKechengbianhao(kechengbianhao);

    String xianyourenshu;

    xianyourenshu=arg0.getParameter("xianyourenshu");

    String gonghao;

    gonghao=arg0.getParameter("gonghao");

    j.setGonghao(gonghao);

    j.setXingming(Service.getXingming());

    j.setXuehao(Service.getXuehao());int num=Integer.parseInt(xianyourenshu);

    num++;

    System.out.println(num);

    Select s=newSelect();

    flag=s.select("jieguo",kechengbianhao,Service.getXuehao());if(flag)

    {

    c.change("class", "xianyourenshu", "kechengbianhao", num+"", kechengbianhao);

    Add a=newAdd();

    a.add("jieguo", j);

    arg0.setAttribute("message", "选课成功");

    arg0.getRequestDispatcher("Right.jsp").forward(arg0, arg1);

    }else{

    arg0.setAttribute("message", "选课重复");

    arg0.getRequestDispatcher("Right.jsp").forward(arg0, arg1);

    }

    }

    }/***@seeHttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)*/

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {//TODO Auto-generated method stub

    response.getWriter().append("Served at: ").append(request.getContextPath());

    }/***@seeHttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)*/

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {//TODO Auto-generated method stub

    doGet(request, response);

    }

    }

    Teacher包中的文件:

    packageTeacher;importjava.sql.Connection;importjava.sql.SQLException;importjava.sql.Statement;importLogin.DBUtil;public classAdd {public booleanadd(String table,KechengService en)

    {boolean c=false;

    String sql="insert into "+table+"(kechengbianhao,kechengmingcheng,gonghao,renkejiaoshi,renshushangxian,xianyourenshu) values('"+en.getKechengbianhao()+"','"+en.getKechengmingcheng()+"','"+en.getGonghao()+"','"+en.getRenkejiaoshi()+"','"+en.getRenshushangxian()+"','"+en.getXianyourenshu()+"');";

    Connection conn=DBUtil.getConn();

    Statement state=null;try{

    state=conn.createStatement();int num=state.executeUpdate(sql);if(num!=0)

    c=true;

    state.close();

    conn.close();

    }catch(SQLException e) {//TODO Auto-generated catch block//e.printStackTrace();

    }returnc;

    }

    }

    packageTeacher;importjava.sql.Connection;importjava.sql.SQLException;importjava.sql.Statement;importLogin.DBUtil;public classChange {public booleanchange(String table,String lie,String lie0,String gai,String biao)

    {

    Connection conn=DBUtil.getConn();

    Statement state=null;try{

    state=conn.createStatement();

    String sql="update "+table+" set "+lie+"='"+gai+"' where "+lie0+"='"+biao+"'";

    System.out.println(sql);

    state.executeUpdate(sql);

    state.close();

    conn.close();

    }catch(SQLException e) {//TODO Auto-generated catch block

    e.printStackTrace();

    }return true;

    }

    }

    packageTeacher;importjava.sql.Connection;importjava.sql.ResultSet;importjava.sql.Statement;importLogin.DBUtil;public classFind {public booleanfind(String table,String id)

    {booleanc;

    Connection conn=DBUtil.getConn();

    Statement state=null;try{

    state=conn.createStatement();

    String sql="select * from "+table+" where xingming ='"+id+"'";

    ResultSet rs=state.executeQuery(sql);while(rs.next())

    {

    Service.setGonghao(rs.getString(1));

    Service.setXingming(rs.getString(2));

    Service.setXingbie(rs.getString(3));

    Service.setXueyuan(rs.getString(4));

    Service.setZhicheng(rs.getString(5));

    }

    rs.close();

    state.close();

    conn.close();

    System.out.println("over");

    }catch(Exception e)

    {

    }return true;

    }

    }

    packageTeacher;importjava.sql.Connection;importjava.sql.PreparedStatement;importjava.sql.ResultSet;importjava.util.ArrayList;importjava.util.List;importLogin.DBUtil;public classGet {public static ListgetAll(String id)

    {

    List list=new ArrayList();

    Connection conn=DBUtil.getConn();

    PreparedStatement state=null;

    ResultSet rs=null;

    String sql="select * from class where gonghao ='"+id+"'";try{

    state=conn.prepareStatement(sql);

    rs=state.executeQuery();while(rs.next())

    {

    KechengService user=newKechengService();

    user.setKechengbianhao(rs.getString(1));

    user.setKechengmingcheng(rs.getString(2));

    user.setGonghao(rs.getString(3));

    user.setRenkejiaoshi(rs.getString(4));

    user.setXianyourenshu(rs.getInt(6));

    list.add(user);

    }

    rs.close();

    state.close();

    conn.close();

    }catch(Exception e)

    {

    }if(list!=null) {returnlist;

    }else{return null;

    }

    }public static ListgetAllxs(String bianhao)

    {

    List list=new ArrayList();

    Connection conn=DBUtil.getConn();

    PreparedStatement state=null;

    ResultSet rs=null;

    String sql="select * from jieguo";try{

    state=conn.prepareStatement(sql);

    rs=state.executeQuery();while(rs.next())

    {if(rs.getString(1).equals(bianhao))

    {

    Xuesheng user=newXuesheng();

    user.setXingming(rs.getString(4));

    user.setXuehao(rs.getString(3));

    list.add(user);

    }

    }

    rs.close();

    state.close();

    conn.close();

    }catch(Exception e)

    {

    }if(list!=null) {returnlist;

    }else{return null;

    }

    }

    }

    packageTeacher;public classKechengService {

    String kechengbianhao;

    String kechengmingcheng;

    String renkejiaoshi;intrenshushangxian;intxianyourenshu;

    String gonghao;publicString getGonghao() {returngonghao;

    }public voidsetGonghao(String gonghao) {this.gonghao =gonghao;

    }publicString getKechengbianhao() {returnkechengbianhao;

    }public voidsetKechengbianhao(String kechengbianhao) {this.kechengbianhao =kechengbianhao;

    }publicString getKechengmingcheng() {returnkechengmingcheng;

    }public voidsetKechengmingcheng(String kechengmingcheng) {this.kechengmingcheng =kechengmingcheng;

    }publicString getRenkejiaoshi() {returnrenkejiaoshi;

    }public voidsetRenkejiaoshi(String renkejiaoshi) {this.renkejiaoshi =renkejiaoshi;

    }public intgetRenshushangxian() {returnrenshushangxian;

    }public void setRenshushangxian(intrenshushangxian) {this.renshushangxian =renshushangxian;

    }public intgetXianyourenshu() {returnxianyourenshu;

    }public void setXianyourenshu(intxianyourenshu) {this.xianyourenshu =xianyourenshu;

    }

    }

    packageTeacher;importjava.io.IOException;importjavax.servlet.ServletException;importjavax.servlet.annotation.WebServlet;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importLogin.Power;importLogin.Select;/*** Servlet implementation class KechengServlet*/@WebServlet("/KechengServlet")public class KechengServlet extendsHttpServlet {private static final long serialVersionUID = 1L;/***@seeHttpServlet#HttpServlet()*/

    publicKechengServlet() {super();//TODO Auto-generated constructor stub

    }protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throwsServletException, IOException

    {

    Select s=newSelect();

    arg0.setCharacterEncoding("utf-8");

    arg1.setCharacterEncoding("utf-8");booleanflag;

    String function=arg0.getParameter("method");if(function.equals("submit"))

    {

    Find f=newFind();

    f.find("teacher", Power.getXingming());

    Add a=newAdd();

    KechengService ks=newKechengService();

    String kechengbianhao;

    kechengbianhao=arg0.getParameter("kechengbianhao");

    ks.setKechengbianhao(kechengbianhao);

    String kechengmingcheng;

    kechengmingcheng=arg0.getParameter("kechengmingcheng");

    ks.setKechengmingcheng(kechengmingcheng);

    String renkejiaoshi;

    renkejiaoshi=Power.getXingming();

    String gonghao;

    gonghao=Service.getGonghao();

    ks.setGonghao(gonghao);

    ks.setRenkejiaoshi(renkejiaoshi);

    String renshushangxian;

    renshushangxian=arg0.getParameter("renshushangxian");int num=Integer.parseInt(renshushangxian);

    ks.setRenshushangxian(num);

    ks.setXianyourenshu(0);

    a.add("class", ks);

    arg0.setAttribute("message", "添加成功");

    arg0.getRequestDispatcher("teacher/tianjiakecheng.jsp").forward(arg0, arg1);

    }

    }/***@seeHttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)*/

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {//TODO Auto-generated method stub

    response.getWriter().append("Served at: ").append(request.getContextPath());

    }/***@seeHttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)*/

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {//TODO Auto-generated method stub

    doGet(request, response);

    }

    }

    packageTeacher;importjava.io.IOException;importjava.util.List;importjavax.servlet.ServletException;importjavax.servlet.annotation.WebServlet;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importLogin.Power;importLogin.Select;/*** Servlet implementation class LiulanServlet*/@WebServlet("/LiulanServlet")public class LiulanServlet extendsHttpServlet {private static final long serialVersionUID = 1L;/***@seeHttpServlet#HttpServlet()*/

    publicLiulanServlet() {super();//TODO Auto-generated constructor stub

    }/***@seeHttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)*/

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {//TODO Auto-generated method stub

    response.getWriter().append("Served at: ").append(request.getContextPath());

    }protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throwsServletException, IOException

    {

    Select s=newSelect();

    arg0.setCharacterEncoding("utf-8");

    arg1.setCharacterEncoding("utf-8");booleanflag;

    String function=arg0.getParameter("method");if(function.equals("liulan"))

    {

    List userall =Get.getAll(Service.getGonghao());

    java.util.Collections.reverse(userall);

    arg0.setAttribute("all", userall);

    arg0.getRequestDispatcher("teacher/liulanxuanke.jsp").forward(arg0, arg1);

    }if(function.equals("xiangxi"))

    {

    String kechengbianhao;

    kechengbianhao=arg0.getParameter("kechengbianhao");

    List userall =Get.getAllxs(kechengbianhao);

    java.util.Collections.reverse(userall);

    arg0.setAttribute("all", userall);

    arg0.getRequestDispatcher("teacher/xiangxi.jsp").forward(arg0, arg1);

    }

    }/***@seeHttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)*/

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {//TODO Auto-generated method stub

    doGet(request, response);

    }

    }

    packageTeacher;public classService {staticString gonghao;staticString xingming;staticString xingbie;staticString xueyuan;public staticString getGonghao() {returngonghao;

    }public static voidsetGonghao(String gonghao) {

    Service.gonghao=gonghao;

    }public staticString getXingming() {returnxingming;

    }public static voidsetXingming(String xingming) {

    Service.xingming=xingming;

    }public staticString getXingbie() {returnxingbie;

    }public static voidsetXingbie(String xingbie) {

    Service.xingbie=xingbie;

    }public staticString getXueyuan() {returnxueyuan;

    }public static voidsetXueyuan(String xueyuan) {

    Service.xueyuan=xueyuan;

    }public staticString getZhicheng() {returnzhicheng;

    }public static voidsetZhicheng(String zhicheng) {

    Service.zhicheng=zhicheng;

    }staticString zhicheng;

    }

    packageTeacher;importjava.io.IOException;importjavax.servlet.ServletException;importjavax.servlet.annotation.WebServlet;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importLogin.Power;/*** Servlet implementation class TXiugaiServlet*/@WebServlet("/TXiugaiServlet")public class TXiugaiServlet extendsHttpServlet {private static final long serialVersionUID = 1L;/***@seeHttpServlet#HttpServlet()*/

    publicTXiugaiServlet() {super();//TODO Auto-generated constructor stub

    }protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throwsServletException, IOException

    {

    arg0.setCharacterEncoding("utf-8");

    arg1.setCharacterEncoding("utf-8");booleanflag;

    String function=arg0.getParameter("method");if(function.equals("submit"))

    {

    Find f=newFind();

    f.find("teacher", Power.getXingming());

    arg0.getRequestDispatcher("teacher/xiugaixinxi.jsp").forward(arg0, arg1);

    }if(function.equals("xiugai"))

    {

    Change c=newChange();

    String xingming;

    xingming=arg0.getParameter("xingming");

    String xingbie;

    xingbie=arg0.getParameter("xingbie");

    String xueyuan;

    xueyuan=arg0.getParameter("xueyuan");

    String zhicheng;

    zhicheng=arg0.getParameter("zhicheng");

    c.change("class", "renkejiaoshi", "gonghao", xingming, Service.getGonghao());

    c.change("login", "name", "username", xingming, Power.getUsername());

    Power.setUsername(xingming);

    c.change("teacher", "xingming", "gonghao", xingming, Service.getGonghao());

    c.change("teacher", "xingbie", "gonghao", xingbie, Service.getGonghao());

    c.change("teacher", "xueyuan", "gonghao", xueyuan, Service.getGonghao());

    c.change("teacher", "zhicheng", "gonghao", zhicheng, Service.getGonghao());

    arg0.setAttribute("message", "修改成功");

    arg0.getRequestDispatcher("Right.jsp").forward(arg0, arg1);

    }

    }/***@seeHttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)*/

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {//TODO Auto-generated method stub

    response.getWriter().append("Served at: ").append(request.getContextPath());

    }/***@seeHttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)*/

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {//TODO Auto-generated method stub

    doGet(request, response);

    }

    }

    packageTeacher;public classXuesheng {

    String xingming;

    String xuehao;publicString getXingming() {returnxingming;

    }public voidsetXingming(String xingming) {this.xingming =xingming;

    }publicString getXuehao() {returnxuehao;

    }public voidsetXuehao(String xuehao) {this.xuehao =xuehao;

    }

    }

    JSP文件中:

    guanli文件夹:

    Insert title here

    //

    //接收servlet传过来的那个message的参数//alert是js语句中的弹出警示框,也就是弹出message中的参数

    Object message=request.getAttribute("message");if(!(message==null||message.equals("")))

    {%>

    账号
    密码
    工号:
    姓名:
    性别:
    所在学院:
    职称:
    Insert title here

    //

    //接收servlet传过来的那个message的参数//alert是js语句中的弹出警示框,也就是弹出message中的参数

    Object message=request.getAttribute("message");if(!(message==null||message.equals("")))

    {%>

    账号
    密码
    学号:
    姓名:
    性别:
    班级:
    专业:

    student文件夹中:

    Insert title here
    工号:
    任课教师
    教师性别
    学院:
    职称
    Insert title here
    课程编号:
    课程名称:
    任课教师:
    课程容量:
    现有人数:
    Insert title here
    课程名称课程编号任课教师
    ${stu.getKechengmingcheng() }${stu.getKechengbianhao() }${stu.getRenkejiaoshi() }
    Insert title here

    //

    //接收servlet传过来的那个message的参数//alert是js语句中的弹出警示框,也就是弹出message中的参数

    Object message=request.getAttribute("message");if(!(message==null||message.equals("")))

    {%>

    学号
    姓名>
    性别>
    班级>
    专业>
    Insert title here
    课程名称课程编号任课教师操作
    ${stu.getKechengmingcheng() }${stu.getKechengbianhao() }${stu.getRenkejiaoshi() }选课

    teacher文件中的:

    Insert title here
    课程名称课程编号现有人数
    ${stu.getKechengmingcheng()}${stu.getKechengbianhao() }${stu.getXianyourenshu() }
    Insert title here

    //

    //接收servlet传过来的那个message的参数//alert是js语句中的弹出警示框,也就是弹出message中的参数

    Object message=request.getAttribute("message");if(!(message==null||message.equals("")))

    {%>

    课程编号
    课程名称
    课程人数
    Insert title here
    姓名学号
    ${stu.getXingming() }${stu.getXuehao() }
    Insert title here

    //

    //接收servlet传过来的那个message的参数//alert是js语句中的弹出警示框,也就是弹出message中的参数

    Object message=request.getAttribute("message");if(!(message==null||message.equals("")))

    {%>

    工号
    姓名>
    性别>
    所在学院>
    职称>

    最下面的JSP文件:

    Insert title here

    //

    //接收servlet传过来的那个message的参数//alert是js语句中的弹出警示框,也就是弹出message中的参数

    Object message=request.getAttribute("message");if(!(message==null||message.equals("")))

    {%>

    Insert title here

    margin:0;

    padding:0;

    font-size: 12px;

    font-family: "Microsoft Yahei", Verdana, Arial, Helvetica, sans-serif

    }

    .leftMenu {

    min-width:220px;

    width:268px;

    margin:40px auto0auto;

    }

    .menu {

    border: #bdd7f2 1px solid;

    border-top: #0080c4 4px solid;

    border-bottom: #0080c4 4px solid;

    background: #f4f9ff repeat-y right;

    margin-left: 10px;

    }

    .menu .ListTitle {

    border-bottom: 1px #98c9ee solid;

    display: block;

    text-align: center;/*position: relative;*/height: 38px;

    line-height: 38px;

    cursor: pointer;/*+min-width:220px;*/

    +width:100%;

    }

    .ListTitlePanel {

    position: relative;

    }

    .leftbgbt {

    position: absolute;

    background: no-repeat;

    width: 11px;

    height: 52px;

    left:-11px;

    top:-4px;

    }/*.leftbgbt {

    float:left;

    background: no-repeat;

    width: 11px;

    height: 52px;

    left: 0px;

    top: 0px;

    zoom:1;

    z-index:200px;

    }*/.leftbgbt2 {

    position: absolute;

    background: no-repeat;

    width: 11px;

    height: 48px;

    left:-11px;

    top:-1px;

    }

    .menuList {

    display: block;

    height: auto;

    }

    .menuList div {

    height: 28px;

    line-height: 24px;

    border-bottom: 1px #98c9ee dotted;

    }

    .menuList div a {

    display: block;

    background: #fff;

    line-height: 28px;

    height: 28px;

    color: #185697;

    text-decoration: none;

    }

    .menuList div a:hover {

    color: #f30;

    background: #0080c4;

    color: #fff;

    }

    //

    //接收servlet传过来的那个message的参数//alert是js语句中的弹出警示框,也就是弹出message中的参数

    int message=Power.getFlag();%>

    >

    登录

    //

    //接收servlet传过来的那个message的参数//alert是js语句中的弹出警示框,也就是弹出message中的参数

    Object message=request.getAttribute("message");if(!(message==null||message.equals("")))

    {%>

    账号:
    密码:
    身份:

    管理员

    教师

    学生

    Insert title here

    //

    //接收servlet传过来的那个message的参数//alert是js语句中的弹出警示框,也就是弹出message中的参数

    Object message=request.getAttribute("message");if(!(message==null||message.equals("")))

    {%>

    Insert title here

    流转系统

    首 页     退出

    以上的代码均按顺序发出。

    现在发一些运行图:

    af6f7f65ef91d59a4f2e6902052f1ac7.png

    管理员:

    5399d76e34be8477aadd9be6a5402a55.png

    学生:

    abde3494638767710bb945a830fcb371.png

    375fd0fbd5f17cc6875280b286364d56.png

    932ddeb9ccacd5cb52dcd63023576517.png

    教师:

    d7b543c4aa61eb2de0f40054bbc0306d.png

    4ae28fdce072a558bc98877aaf3fea19.png

    展开全文
  • 摘要 1 Abstract 2 1、引言 3 1.1 课题研究的目的 4 1.2 课题研究的意义 4 ...5.3 选课 20 5.4 退课 21 5.5 密码修改 21 5.6 管理员登录 21 5.7 退出系统 22 6、调和测试 22 结 论 24 致 谢 25 参 考 文 献 26
  • javaweb-选课管理系统

    2018-03-05 14:40:26
    选课管理系统,使用ssh框架搭建。
  • javaweb学生信息选课管理系统源代码。javaweb学生信息选课管理系统--老师学生双用户; 额外实现了成绩单页面转pdf与打印下载接口; oracle/mysql jsp servlet 有助于初学者学习深入 javaweb学生信息选课管理系统源...
  • 基于互联网的学生网上选课系统作为计算机应用的一部分,使用计算机对选课信息进行管理,有着手工管理所无法比拟的优点,例如:检索迅速、查找方便、可靠性高、存储量大、保密性好、寿命长、成本低等。这些优点能够极大...
  • JavaWeb学生选课系统

    2021-07-26 11:00:17
    JavaWeb学生选课系统采用eclipse开发,Tomcat8 ,MySQL5.5以上,jdk1.8 系统分为管理员,教师,学生 包含课程管理,选课管理,学生管理,教师管理等模块
  • 学生信息管理、班级信息管理、教师信息管理、课程信息管理、选课信息管理、考勤信息管理、请假信息管理、成绩信息管理、系统管理 3.系统管理员 学生信息管理、班级信息管理、教师信息管理、课程信息管理、选课信息...
  • 在线选课系统通过Web应用程序的方式实现在线选课的流程。学生登录系统后可以查看所有课程的选课情况,并且可以对选课人数没有满员的课程进行选课操作,同时也可以查询自己已经选择了那些课程;教师登录系统后可以...
  • 选课系统着重应用JAVA WEB技术包括:JSP技术以及JDBC连接数据库。使用前台的技术包括JSP,JavaScript,CSS等。数据库采用MySQL。开发环境采用MyEclipse 14。 系统设计部分主要介绍了系统详细功能设计、数据库设计...
  • JavaWeb学生选课系统 学生管理系统

    千次阅读 多人点赞 2021-06-16 21:15:36
    今天,博主完成了一个JavaWeb的学生选课系统,该项目是使用已有数据库工具类的基础上进行开发的,同时使用了BootStrap前端框架,使前端界面更加美观,该系统功能三个用户角色,分别为学生,教师,超管。 功能上实现...

    今天,博主完成了一个JavaWeb的学生选课系统,该项目是使用已有数据库工具类的基础上进行开发的,同时使用了BootStrap前端框架,使前端界面更加美观,该系统功能三个用户角色,分别为学生,教师,超管。
    功能上实现了学生登录网站选择课程,
    教师添加课程信息与学生信息,修改课程成绩,
    管理员进行教师管理,课程管理,学生管理,选课管理

    首先我们需要了解数据库表的结构
    教师表
    在这里插入图片描述
    学生表
    在这里插入图片描述
    课程表
    在这里插入图片描述
    选课表
    在这里插入图片描述
    通过数据表的信息我们可以了解各个实体间的关系(E-R图仅供参考)
    在这里插入图片描述
    接下来,便是项目展示

    项目效果图展示

    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    以上便是学生选课系统的展示模块,该系统的开发关键在于理解各个角色之间的关系,以及对该套数据库工具的熟练使用。
    以上便是学生选课系统的详细内容,码字不易,给个赞呗,哈哈哈

    数据库工具类即相关功能开发欲了解可参考博主这边博文

    数据库工具类讲解与实现一个销售系统

    展开全文
  • 基于javaweb的学生选课系统(java+javaweb+jdbc) 功能介绍: 用户菜单、学生管理、教师管理、课程管理、成绩排名查询 适用 课程设计,大作业,毕业设计,项目练习,学习演示等 if(StringUtils.isEmpty(user....

    基于javaweb的学生选课系统(java+javaweb+jdbc)
    功能介绍:
    用户菜单、学生管理、教师管理、课程管理、成绩排名查询请添加图片描述
    请添加图片描述
    请添加图片描述

    适用

    课程设计,大作业,毕业设计,项目练习,学习演示等

            if(StringUtils.isEmpty(user.getUserName())){
                return MapControl.getInstance().error("请填写用户名").getMap();
            }
            if(StringUtils.isEmpty(user.getName())){
                return MapControl.getInstance().error("请填写名称").getMap();
            }
            if(StringUtils.isEmpty(user.getUserPwd())){
                return MapControl.getInstance().error("请填写密码").getMap();
            }
            int result = userService.create(user);
            if (result <= 0) {
                return MapControl.getInstance().error().getMap();
            }
            return MapControl.getInstance().success().getMap();
        }
        /**
         * 根据id删除
         * @param id
         * @return
         */
        @PostMapping("/delete/{id}")
        @ResponseBody
        public Map<String, Object> delete(@PathVariable("id") Integer id) {
            int result = userService.delete(id);
            if (result <= 0) {
                return MapControl.getInstance().error().getMap();
    
                return MapControl.getInstance().error("请填写身份证号").getMap();
            }
            if(StringUtils.isEmpty(student.getPhone())){
                return MapControl.getInstance().error("请填写手机号码").getMap();
            }
            int result = studentService.saveU(student);
            if (result <= 0) {
                return MapControl.getInstance().error().getMap();
            }
            return MapControl.getInstance().success().getMap();
        }
        //根据id查询,跳转修改页面
        @GetMapping("/edit/{id}")
        public String detail(@PathVariable("id") Integer id, ModelMap modelMap) {
            //查询出要修改的学生的信息
            Student student = studentService.detail(id);
            //查询所有的专业
            List<Subject> subjects = subjectService.query(null);
            //将查询出来的数据存储到request域,实现表单回显
            modelMap.addAttribute("student", student);
            modelMap.addAttribute("subjects", subjects);
            return "student/edit";
        }
        //查询所有
        @PostMapping("/query")
    
            //查询出要修改的学生的信息
            Student student = studentService.detail(id);
            //查询所有的专业
            List<Subject> subjects = subjectService.query(null);
            //将查询出来的数据存储到request域,实现表单回显
            modelMap.addAttribute("student", student);
            modelMap.addAttribute("subjects", subjects);
            return "student/edit";
        }
        //查询所有
        @PostMapping("/query")
        @ResponseBody
        public Map<String, Object> query(@RequestBody Student student) {
            //查询所有的学生信息
            List<Student> list = studentService.query(student);
            //查询所有的专业
            List<Subject> subjects = subjectService.query(null);
            //查询所有的班级
            List<Clazz> clazzes = clazzService.query(null);
            //设置关联
            list.forEach(entity -> {
                subjects.forEach(subject -> {
                    //判断学生表中的subjectId和专业表的id是否一致
                    if (subject.getId() == entity.getSubjectId()) {
                        entity.setSubject(subject);
                    }
                });
    
         * 编辑用户信息操作
         * @param user
         * @return
         */
        @PostMapping("/edit")
        @ResponseBody
        public Map<String, Object> edit(@RequestBody User user) {
            if(StringUtils.isEmpty(user.getUserName())){
                return MapControl.getInstance().error("请填写用户名").getMap();
            }
            if(StringUtils.isEmpty(user.getName())){
                return MapControl.getInstance().error("请填写名称").getMap();
            }
            if(StringUtils.isEmpty(user.getUserPwd())){
                return MapControl.getInstance().error("请填写密码").getMap();
            }
            int result = userService.update(user);
            if (result <= 0) {
                return MapControl.getInstance().error().getMap();
            }
            return MapControl.getInstance().success().getMap();
    
                    //判断学生表的subjectId和专业表的id是否一致
                    if (subject.getId() == entity.getSubjectId()) {
                        entity.setSubject(subject);
                    }
                });
                clazzes.forEach(clazz -> {
                    //判断学生表的clazzId和班级表的id是否一致
                    if (clazz.getId() == entity.getClazzId()) {
                        entity.setClazz(clazz);
                    }
                });
            });
            return MapControl.getInstance().success().add("data", students).getMap();
        }
    }
    用户管理操作:
    /**
     * 用户管理操作
     */
    @Controller
    
                    return MapControl.getInstance().success().add("data", user).getMap();
                } else {
                    return MapControl.getInstance().error("用户名或密码错误").getMap();
                }
            }
            if ("2".equals(type)) { //老师验证登录
                Teacher teacher = teacherService.login(userName, MD5Utils.getMD5(password));
                if (teacher != null) {
                    session.setAttribute("user", teacher);
                    session.setAttribute("type", "2");
                    return MapControl.getInstance().success().add("data", teacher).getMap();
                } else {
                    return MapControl.getInstance().error("用户名或密码错误").getMap();
    
                Teacher teacher = teacherService.login(userName, MD5Utils.getMD5(password));
                if (teacher != null) {
                    session.setAttribute("user", teacher);
                    session.setAttribute("type", "2");
                    return MapControl.getInstance().success().add("data", teacher).getMap();
                } else {
                    return MapControl.getInstance().error("用户名或密码错误").getMap();
                }
            }
            if ("3".equals(type)) { //学生验证登录
                Student student = studentService.login(userName, MD5Utils.getMD5(password));
                if (student != null) {
                    session.setAttribute("user", student);
                    session.setAttribute("type", "3");
                    return MapControl.getInstance().success().add("data", student).getMap();
                } else {
                    return MapControl.getInstance().error("用户名或密码错误").getMap();
                }
            }
            return MapControl.getInstance().getMap();
        }
    学生管理控制层:
    
        @Autowired
        private SubjectService subjectService;
        @Autowired
        private ClazzService clazzService;
        //跳转添加页面
        @GetMapping("/add")
        public String add(ModelMap modelMap) {
            //查询所有的专业,存储到request域
            List<Subject> subjects = subjectService.query(null);
            modelMap.addAttribute("subjects", subjects);
            return "student/add";
        }
        /**
         * 学生添加操作
         * @param student
         * @return
         */
        @PostMapping("/add")
        @ResponseBody
        public Map<String, Object> add(@RequestBody Student student) {
    
                    //判断学生表中的subjectId和专业表的id是否一致
                    if (subject.getId() == entity.getSubjectId()) {
                        entity.setSubject(subject);
                    }
                });
                clazzes.forEach(clazz -> {
                    //判断学生表中的clazzId和班级表的id是否一致
                    if (clazz.getId() == entity.getClazzId()) {
                        entity.setClazz(clazz);
                    }
                });
            });
            //查询总记录条数
    
            //查询所有的专业,存储到request域
            List<Subject> subjects = subjectService.query(null);
            modelMap.addAttribute("subjects", subjects);
            return "student/add";
        }
        /**
         * 学生添加操作
         * @param student
         * @return
         */
        @PostMapping("/add")
        @ResponseBody
        public Map<String, Object> add(@RequestBody Student student) {
    
    展开全文
  • 学生选课系统 技术实现: 后台框架:Servlet、JSP、JDBC、DbUtils ​ UI界面:EasyUI、jQuery、Ajax ​ 数据库:MySQL 系统功能: 系统共分为三种用户: 1. 学生模块 学生信息管理、选课信息管理、考勤信息...
  • 源码参考,欢迎i下载
  • JavaWeb项目-选课系统

    2021-02-28 17:52:11
    1 packagetest1;2 import java.sql.*;3 importjava.util.regex.Pattern;45 public classData {6 //common7 privateString userid;8 privateString password;9 privateString name;10 privateStr...
  • 基于javaweb的高校学生选课系统项目源码,包含项目说明文档、源码、使用说明,数据库等一系列辅助文档
  • 学生选课系统,也可以说教务管理系统,功能比较多,可做课程设计和毕业设计参考,角色分为学生,老师,管理员,分别对应不同的操作 学生:注册登录,修改信息,查看选课信息,查看成绩,查看公告,课程信息管理 教师...
  • 学习javaWEB的快速入门项目,学生选课系统,使用jsp+servlet技术 数据库使用mysql数据库 采用jdbc+Dbutils组件;使用的db连接池是c3p0。
  • 学生选课系统 Javaweb版的

    热门讨论 2009-09-24 19:09:57
    学生在线选课系统,web版本,可以校验课时冲突!!!!
  • 选课系统_javaweb程序

    2020-10-10 22:01:22
    使用javaweb程序,进行设计一个选课系统。包中存在设计的数据库表、和相应源代码信息,供大家进行参考。

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 1,878
精华内容 751
关键字:

javaweb选课系统

java 订阅