package DAO;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import Bean.CollegeManagerBean;
import Bean.HeadTeacherBean;
import Bean.StudentBean;
import Bean.TeacherBean;
public class CollegeManagerDAO {
private static InitialContext context = null;
private DataSource dataSource = null;
private static final String WHETHER_STUDENT_DELETE_SQL= "SELECT * FROM student_table WHERE id=? and college=?";
private static final String DELETE_STUDENT_SQL = "DELETE FROM student_table WHERE id=?";
private static final String ADD_STUDENT_SQL = "insert into student_table values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
private static final String UPDATE_STUDENT_SQL="update student_table set name=?,gender=?,classes=?,professional=?,entrance_year=?,degree=?,phone=?,email=?,address=?,postcode=?,username=?,password=? where id=?";
private static final String SELECT_STUDENT_SQL = "SELECT * FROM student_table WHERE id=? and college=?";
private static final String WHETHER_TEACHER_DELETE_SQL = "SELECT * FROM teacher_table WHERE id=? and college=?";
private static final String DELETE_TEACHER_SQL = "DELETE FROM teacher_table WHERE id=?";
private static final String ADD_TEACHER_SQL = "insert into teacher_table values(?,?,?,?,?,?)";
private static final String UPDATE_TEACHER_SQL="update teacher_table set classes=?,professional=?,username=?,password=? where id=?";
private static final String SELECT_COLLEGEMANAGER_SQL = "SELECT * FROM collegemanager_table WHERE username=? and password=?";
private static final String WHETHER_HEADTEACHER_DELETE_SQL = "SELECT * FROM headteacher_table WHERE id=? and college=?";
private static final String DELETE_HEADTEACHER_SQL = "DELETE FROM headteacher_table WHERE id=?";
private static final String ADD_HEADTEACHER_SQL = "insert into headteacher_table values(?,?,?,?,?,?)";
private static final String UPDATE_HEADTEACHER_SQL="update headteacher_table set classes=?,professional=?,username=?,password=? where id=?";
private static final String SELECT_BY_COLLEGE_SQL = "SELECT * FROM student_table WHERE college=?";
public CollegeManagerDAO() {
try {
if (context == null) {
context = new InitialContext();
}
dataSource = (DataSource) context
.lookup("java:comp/env/jdbc/sampleDS");
} catch (NamingException e2) {
}
}
public Connection getConnection() {
Connection conn = null;
try {
conn = dataSource.getConnection();
} catch (SQLException e) {
}
return conn;
}
public boolean whetherstudentcanbedelete(String id,String college){
boolean b=false;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rst = null;
try {
conn = dataSource.getConnection();
pstmt = conn.prepareStatement(WHETHER_STUDENT_DELETE_SQL);
pstmt.setString(1, id);
pstmt.setString(2, college);
rst = pstmt.executeQuery();
if (rst.next())
b=true;
rst.close();
pstmt.close();
return b;
} catch (Exception se) {
return b;
}
}
public void deleteStudent(String id) {
Connection conn = null;
PreparedStatement pstmt = null;
try {
conn = dataSource.getConnection();
pstmt = conn.prepareStatement(DELETE_STUDENT_SQL);
pstmt.setString(1, id);
pstmt.executeUpdate();
pstmt.close();
} catch (Exception se) {
}
return;
}
public void addStudent(String id,String name,String gender,String classes,String professional,String college,String entrance_year,String degree,String phone,String email,String address,String postcode,String username,String password) {
Connection conn = null;
PreparedStatement pstmt = null;
try {
conn = dataSource.getConnection();
pstmt = conn.prepareStatement(ADD_STUDENT_SQL);
pstmt.setString(1,id);
pstmt.setString(2,name);
pstmt.setString(3,gender);
pstmt.setString(4,classes);
pstmt.setString(5, professional);
pstmt.setString(6,college);
pstmt.setString(7, entrance_year);
pstmt.setString(8, degree);
pstmt.setString(9, phone);
pstmt.setString(10, email);
pstmt.setString(11,address);
pstmt.setString(12,postcode);
pstmt.setString(13, username);
pstmt.setString(14, password);
pstmt.executeUpdate();
pstmt.close();
} catch (Exception se) {
}
return ;
}
public void updateStudent(String name,String gender,String classes,String professional,String entrance_year,String degree,String phone,String email,String address,String postcode,String username,String password,String id) {
Connection conn = null;
PreparedStatement pstmt = null;
try {
conn = dataSource.getConnection();
pstmt = conn.prepareStatement(UPDATE_STUDENT_SQL);
pstmt.setString(1,name);
pstmt.setString(2,gender);
pstmt.setString(3,classes);
pstmt.setString(4,professional);
pstmt.setString(5,entrance_year);
pstmt.setString(6,degree);
pstmt.setString(7,phone);
pstmt.setString(8,email);
pstmt.setString(9,address);
pstmt.setString(10,postcode);
pstmt.setString(11, username);
pstmt.setString(12, password);
pstmt.setString(13,id);
pstmt.executeUpdate();
pstmt.close();
return;
} catch (Exception se) {
}
return ;
}
public StudentBean collegemanagersearchStudent(String id,String college) {
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rst = null;
StudentBean student = new StudentBean();
try {
conn = dataSource.getConnection();
pstmt = conn.prepareStatement(SELECT_STUDENT_SQL);
pstmt.setString(1, id);
pstmt.setString(2,college);
rst = pstmt.executeQuery();
if (rst.next()) {
student.setId(rst.getString("id"));
student.setName(rst.getString("name"));
student.setGender(rst.getString("gender"));
student.setClasses(rst.getString("classes"));
student.setProfessional(rst.getString("professional"));
student.setCollege(rst.getString("college"));
student.setEntrance_year(rst.getString("entrance_year"));
student.setDegree(rst.getString("degree"));
student.setPhone(rst.getString("phone"));
student.setEmail(rst.getString("email"));
student.setAddress(rst.getString("id"));
student.setPostcode(rst.getString("postcode"));
student.setUsername(rst.getString("username"));
student.setPassword(rst.getString("password"));
}
rst.close();
pstmt.close();
} catch (Exception se) {
return null;
}
return student;
}
public boolean whetherteachercanbedelete(String id,String college){
boolean b=false;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rst = null;
try {
conn = dataSource.getConnection();
pstmt = conn.prepareStatement(WHETHER_TEACHER_DELETE_SQL);
pstmt.setString(1, id);
pstmt.setString(2, college);
rst = pstmt.executeQuery();
if (rst.next())
b=true;
rst.close();
pstmt.close();
return b;
} catch (Exception se) {
return b;
}
}
public void deleteTeacher(String id) {
Connection conn = null;
PreparedStatement pstmt = null;
try {
conn = dataSource.getConnection();
pstmt = conn.prepareStatement(DELETE_TEACHER_SQL);
pstmt.setString(1, id);
pstmt.executeUpdate();
pstmt.close();
} catch (Exception se) {
}
return;
}
public void addTeacher(String id,String classes,String professional,String college,String username,String password) {
Connection conn = null;
PreparedStatement pstmt = null;
try {
conn = dataSource.getConnection();
pstmt = conn.prepareStatement(ADD_TEACHER_SQL);
pstmt.setString(1
没有合适的资源?快使用搜索试试~ 我知道了~
学生信息管理系统网站(JSP+JavaBean+Servlet)
共153个文件
java:46个
class:46个
jsp:16个
5星 · 超过95%的资源 需积分: 42 164 下载量 149 浏览量
2012-07-08
17:36:21
上传
评论 13
收藏 1.1MB ZIP 举报
温馨提示
搭建在Tomcat 7.0服务器上,使用的数据库为postgreSQL 资源内含技术说明,使用说明等文档,可以很清楚的了解网站内部功能的实现方法。网站由学生模块,普通教师模块,班主任模块,学院管理员模块,学校管理员模块等部分组成,可以实现对学生和教师信息的增删改查。
资源推荐
资源详情
资源评论
收起资源包目录
学生信息管理系统网站(JSP+JavaBean+Servlet) (153个子文件)
manage_save.backup 12KB
CollegeManagerDAO.class 10KB
SchoolManagerDAO.class 8KB
HeadTeacherDAO.class 7KB
TeacherDAO.class 6KB
LoginServlet.class 5KB
test.class 4KB
HeadTeacher_add_studentServlet.class 3KB
CollegeManager_add_studentServlet.class 3KB
SchoolManager_updateStudentServlet.class 3KB
SchoolManager_Add_studentServlet.class 3KB
CollegeManager_UpdateStudentServlet.class 3KB
StudentBean.class 3KB
HeadTeacher_UpdateServlet.class 3KB
StudentDAO.class 3KB
CollegeManager_add_headteacherServlet.class 3KB
Teacher_search_by_professionalServlet.class 3KB
CollegeManager_add_teacherServlet.class 3KB
Teacher_search_by_ClassesServlet.class 3KB
CollegeManager_preUpdateHeadTeacherServlet.class 3KB
CollegeManager_showstudentServlet.class 2KB
CollegeManager_search_studentServlet.class 2KB
CollegeManager_preUpdateTeacherServlet.class 2KB
HeadTeacher_search_studentServlet.class 2KB
HeadTeacher_showStudentServlet.class 2KB
Teacher_search_by_CollegeServlet.class 2KB
CollegeManager_preUpdateStudentServlet.class 2KB
CollegeManager_delete_headteacherServlet.class 2KB
Teacher_search_byidServlet.class 2KB
CollegeManager_updateheadteacherServlet.class 2KB
CollegeManager_delete_studentServlet.class 2KB
CollegeManger_delete_teacherServlet.class 2KB
CollegeManager_updateTeacherServlet.class 2KB
SchoolManager_showstudentServlet.class 2KB
HeadTeacher_preUpdateServlet.class 2KB
HeadTeacher_delete_studentServlet.class 2KB
SchoolManager_preUpdatestudentServlet.class 2KB
SchoolManager_searchstudentServlet.class 2KB
SchoolManager_updateCollegeServlet.class 2KB
SchoolManager_preUpdateCollegeServlet.class 2KB
SchoolManager_add_collegeServlet.class 2KB
SchoolManager_delete_studentServlet.class 2KB
SchoolManager_delete_collegeServlet.class 2KB
HeadTeacherBean.class 1KB
TeacherBean.class 1KB
CollegeManagerBean.class 1KB
SchoolManagerBean.class 742B
.classpath 529B
org.eclipse.wst.common.component 456B
org.eclipse.wst.jsdt.ui.superType.container 49B
admin.css 2KB
admin.css 2KB
技术报告.doc 799KB
系统使用说明书.doc 369KB
实验报告.doc 67KB
admin_p.gif 4KB
bg.gif 1KB
tabbg01.gif 1KB
tabbg02.gif 1KB
off.gif 920B
folder.gif 919B
login_6.gif 898B
tb-btn-sprite_03.gif 853B
tabbg2.gif 502B
tabbg1.gif 372B
bt_login.gif 300B
h2bg.gif 152B
menu_icon.gif 64B
CollegeManagerDAO.java 13KB
SchoolManagerDAO.java 10KB
HeadTeacherDAO.java 8KB
TeacherDAO.java 8KB
LoginServlet.java 6KB
test.java 4KB
SchoolManager_updateStudentServlet.java 4KB
CollegeManager_add_studentServlet.java 4KB
CollegeManager_UpdateStudentServlet.java 4KB
SchoolManager_Add_studentServlet.java 4KB
HeadTeacher_add_studentServlet.java 3KB
HeadTeacher_UpdateServlet.java 3KB
CollegeManager_showstudentServlet.java 3KB
HeadTeacher_showStudentServlet.java 3KB
Teacher_search_by_professionalServlet.java 3KB
SchoolManager_showstudentServlet.java 3KB
CollegeManager_add_teacherServlet.java 3KB
Teacher_search_by_CollegeServlet.java 3KB
CollegeManager_add_headteacherServlet.java 3KB
CollegeManager_delete_studentServlet.java 3KB
CollegeManager_preUpdateStudentServlet.java 3KB
Teacher_search_by_ClassesServlet.java 3KB
CollegeManager_preUpdateHeadTeacherServlet.java 3KB
CollegeManager_search_studentServlet.java 3KB
HeadTeacher_search_studentServlet.java 3KB
CollegeManager_delete_headteacherServlet.java 3KB
CollegeManger_delete_teacherServlet.java 3KB
CollegeManager_preUpdateTeacherServlet.java 3KB
CollegeManager_updateheadteacherServlet.java 3KB
SchoolManager_delete_studentServlet.java 3KB
SchoolManager_preUpdatestudentServlet.java 3KB
CollegeManager_updateTeacherServlet.java 3KB
共 153 条
- 1
- 2
taiyouqule
- 粉丝: 7
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页