学生管理系统(JSP+MYSQL+SERVELET)

  • b285BuW25Z
    了解作者
  • Java
    开发工具
  • 9.5MB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 0
    下载次数
  • 2022-11-30 02:09
    上传日期
适合学习前端的新手实践的一个项目,快来一起学习前端吧。
dormitoryms.zip
内容介绍
package com.southwind.dao.impl; import com.southwind.dao.StudentDao; import com.southwind.entity.DormitoryAdmin; import com.southwind.entity.Student; import com.southwind.util.JDBCUtil; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; public class StudentDaoImpl implements StudentDao { @Override public List<Student> list() { Connection connection = JDBCUtil.getConnection(); String sql = "select s.id,s.number,s.name,s.gender,s.dormitory_id,d.name,s.state,s.create_date from student s,dormitory d where s.dormitory_id = d.id"; PreparedStatement statement = null; ResultSet resultSet = null; List<Student> list = new ArrayList<>(); try { statement = connection.prepareStatement(sql); resultSet = statement.executeQuery(); while (resultSet.next()) { int id = resultSet.getInt(1); String number = resultSet.getString(2); String name = resultSet.getString(3); String gender = resultSet.getString(4); Integer dormitoryId = resultSet.getInt(5); String dormitoryName = resultSet.getString(6); String state = resultSet.getString(7); String createDate = resultSet.getString(8); list.add(new Student(id, number, name, gender, dormitoryId, dormitoryName, state, createDate)); } } catch (SQLException throwables) { throwables.printStackTrace(); } finally { JDBCUtil.release(connection, statement, resultSet); } return list; } @Override public List<Student> search(String key, String value) { Connection connection = JDBCUtil.getConnection(); String sql = "select s.id,s.number,s.name,s.gender,s.dormitory_id,d.name,s.state,s.create_date from student s,dormitory d where s.dormitory_id = d.id and s."+key+" like '%"+value+"%'"; PreparedStatement statement = null; ResultSet resultSet = null; List<Student> list = new ArrayList<>(); try { statement = connection.prepareStatement(sql); resultSet = statement.executeQuery(); while (resultSet.next()) { int id = resultSet.getInt(1); String number = resultSet.getString(2); String name = resultSet.getString(3); String gender = resultSet.getString(4); Integer dormitoryId = resultSet.getInt(5); String dormitoryName = resultSet.getString(6); String state = resultSet.getString(7); String createDate = resultSet.getString(8); list.add(new Student(id, number, name, gender, dormitoryId, dormitoryName, state, createDate)); } } catch (SQLException throwables) { throwables.printStackTrace(); } finally { JDBCUtil.release(connection, statement, resultSet); } return list; } @Override public Integer save(Student student) { Connection connection = JDBCUtil.getConnection(); String sql = "insert into student(number,name,gender,dormitory_id,state,create_date) values(?,?,?,?,?,?)"; PreparedStatement statement = null; Integer result = null; try { statement = connection.prepareStatement(sql); statement.setString(1, student.getNumber()); statement.setString(2, student.getName()); statement.setString(3, student.getGender()); statement.setInt(4, student.getDormitoryId()); statement.setString(5, student.getState()); statement.setString(6, student.getCreateDate()); result = statement.executeUpdate(); } catch (SQLException throwables) { throwables.printStackTrace(); } finally { JDBCUtil.release(connection, statement, null); } return result; } @Override public Integer update(Student student) { Connection connection = JDBCUtil.getConnection(); String sql = "update student set number = ?,name = ?,gender = ?,dormitory_id = ? where id = ?"; PreparedStatement statement = null; Integer result = null; try { statement = connection.prepareStatement(sql); statement.setString(1, student.getNumber()); statement.setString(2, student.getName()); statement.setString(3, student.getGender()); statement.setInt(4, student.getDormitoryId()); statement.setInt(5, student.getId()); result = statement.executeUpdate(); } catch (SQLException throwables) { throwables.printStackTrace(); } finally { JDBCUtil.release(connection, statement, null); } return result; } @Override public Integer delete(Integer id) { Connection connection = JDBCUtil.getConnection(); String sql = "delete from student where id = "+id; PreparedStatement statement = null; Integer result = null; try { statement = connection.prepareStatement(sql); result = statement.executeUpdate(); } catch (SQLException throwables) { throwables.printStackTrace(); } finally { JDBCUtil.release(connection, statement, null); } return result; } @Override public List<Integer> findStudentIdByDormitoryId(Integer id) { Connection connection = JDBCUtil.getConnection(); String sql = "select id from student where dormitory_id ="+id; PreparedStatement statement = null; ResultSet resultSet = null; List<Integer> list = new ArrayList<>(); try { statement = connection.prepareStatement(sql); resultSet = statement.executeQuery(); while (resultSet.next()) { list.add(resultSet.getInt(1)); } } catch (SQLException throwables) { throwables.printStackTrace(); } finally { JDBCUtil.release(connection, statement, resultSet); } return list; } @Override public Integer updateDorimtory(Integer studentId, Integer dormitoryId) { Connection connection = JDBCUtil.getConnection(); String sql = "update student set dormitory_id = ? where id = ?"; PreparedStatement statement = null; Integer result = null; try { statement = connection.prepareStatement(sql); statement.setInt(1, dormitoryId); statement.setInt(2, studentId); result = statement.executeUpdate(); } catch (SQLException throwables) { throwables.printStackTrace(); } finally { JDBCUtil.release(connection, statement, null); } return result; } @Override public List<Student> moveoutList() { Connection connection = JDBCUtil.getConnection(); String sql = "select s.id,s.number,s.name,s.gender,s.dormitory_id,d.name,s.state from student s,dormitory d where s.dormitory_id = d.id and s.state = '入住'"; PreparedStatement statement = null; ResultSet resultSet = null; List<Student> list = new ArrayList<>(); try { statement = connection.prepareStatement(sql); resultSet = statement.executeQuery(); while (resultSet.next()) { int id = resultSet.getInt(1); String number = resultSet.getString(2); String name = resultSet.getString(3);
评论
    相关推荐
    • 学生管理系统 java
      使用DAO模式实现学生管理系统, 1、 DatabaseConnection 2、 VO 3、 DAO 4、 Impl 5、 Proxy 6、 Factory 有前台界面,数据库使用oracle数据库,简单实例,供大家学习交流。
    • 学生管理系统java
      JAVA语言编程后台用oracle数据库做的学生管理系统
    • 学生管理系统java
      学生管理系统,使用java编程。 学生管理系统,使用java编程。 学生管理系统,使用java编程。
    • 学生管理系统 java
      一套java语言开发的学生管理系统 ,数据库采用sql2000
    • 学生管理系统JAVA
      JAVA初学者很实用,非常简单。相信你能用的上。
    • 学生管理系统 java
      学生管理系统,包含录入学生,删除学生,显示信息排序等功能,是用java开发的图形化界面的版本,ide是eclipse
    • 学生管理系统 java
      学生管理系统 java 实现 若已安装Jbuilder X,则可以直接用Jbuilder X打开.jpx文件,在编程环境中就可以直接运行。(若使用较低版本Jbuilder打开,可能会发生类库缺失错误,具体请查看相应版本的Jbuilder帮助信息。...
    • 学生管理系统java
      学生管理系统java
    • 学生管理系统java
      学生管理系统java
    • 学生管理系统 JAVA
      java语言,access数据库,界面简洁大方,代码易懂,使用JBuilder开发 初学者可参考该系统来研究java