package com.studentManagement.daoImpl;
import com.studentManagement.dao.StudentDao;
import com.studentManagement.po.Student;
import com.studentManagement.po.Student_Leader;
import com.studentManagement.po.Student_simple;
import com.studentManagement.utils.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;
/**
* Created by Administrator on 2017/5/1 0001.
*/
public class StudentDaoImpl implements StudentDao {
private Connection conn = JdbcUtil.getConnection();
private ResultSet resultSet = null;
private PreparedStatement preparedStatement = null;
@Override//查询学生信息(class_id)(sql分页)
public List<Student_simple> queryStudentByClass_id(String class_id, int begin, int end) {
List<Student_simple> arrayList = new ArrayList<>();
String sql = "SELECT\n" +
"\tstudent_id,\n" +
"\tstudent_name,\n" +
"\tstudent_sex,\n" +
"\tstudent_state,\n" +
"\tstudent_qq\n" +
"FROM\n" +
"\tstudents\n" +
"WHERE student_class_id=?\n" +
"LIMIT ?,?";
try {
preparedStatement = conn.prepareStatement(sql);
preparedStatement.setString(1, class_id);
preparedStatement.setInt(2, begin);
preparedStatement.setInt(3, end);
resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
Student_simple student = new Student_simple();
student.setStudent_id(resultSet.getString(1));
student.setStudent_name(resultSet.getString(2));
student.setStudent_sex(resultSet.getString(3));
student.setStudent_state(resultSet.getInt(4));
student.setStudent_qq(resultSet.getString(5));
arrayList.add(student);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
JdbcUtil.closeStatementAndResultSet(resultSet, preparedStatement);
JdbcUtil.closeConnection(conn);
}
return arrayList;
}
@Override//查询学生头像路径(student_id)
public String queryStudentImg(String student_id) {
String sql="SELECT students.student_image_Path FROM students WHERE student_id = ?";
String stuentImg="";
try {
preparedStatement=conn.prepareStatement(sql);
preparedStatement.setString(1,student_id);
resultSet=preparedStatement.executeQuery();
while (resultSet.next()){
stuentImg=resultSet.getString(1);
}
} catch (SQLException e) {
e.printStackTrace();
}finally {
JdbcUtil.closeStatementAndResultSet(resultSet,preparedStatement);
JdbcUtil.closeConnection(conn);
}
return stuentImg;
}
@Override//查询学生详细信息(student_id)
public Student queryStudentDetail(String student_id) {
String sql="SELECT *FROM students WHERE student_id=?";
Student student =new Student();
try {
preparedStatement=conn.prepareStatement(sql);
preparedStatement.setString(1,student_id);
resultSet=preparedStatement.executeQuery();
while (resultSet.next()){
student.setStudent_id(resultSet.getString(1));
student.setStudent_name(resultSet.getString(2));
student.setStudent_key(resultSet.getString(3));
student.setStudent_sex(resultSet.getString(4));
student.setStudent_age(resultSet.getInt(5));
student.setStudent_state(resultSet.getInt(6));
student.setStudent_credit(resultSet.getDouble(7));
student.setStudent_phone(resultSet.getString(8));
student.setStudent_address(resultSet.getString(9));
student.setStudent_qq(resultSet.getString(10));
student.setStudent_nation(resultSet.getString(11));
student.setStudent_dormitory_id(resultSet.getString(12));
student.setStudent_class_id(resultSet.getString(13));
student.setStudent_duty(resultSet.getString(14));
student.setStudent_enter_year(resultSet.getString(15));
student.setStudent_image_Path(resultSet.getString(16));
}
} catch (SQLException e) {
e.printStackTrace();
}finally {
JdbcUtil.closeStatementAndResultSet(resultSet,preparedStatement);
JdbcUtil.closeConnection(conn);
}
return student;
}
@Override//更新学生详细信息(student_id)
public boolean updateStudentDetail(Student student) {
boolean boo=false;
String sql="UPDATE students\n" +
"SET student_name =?, student_key =?, student_sex =?, student_age =?, student_state =?, student_credit =?, student_phone =?, student_address =?, student_qq =?, student_nation =?, student_dormitory_id =?, student_class_id =?, student_duty =?, student_enter_year =?,\n" +
" student_image_Path =?\n" +
"WHERE\n" +
"\tstudent_id =?";
try {
preparedStatement=conn.prepareStatement(sql);
preparedStatement.setString(1,student.getStudent_name());
preparedStatement.setString(2,student.getStudent_key());
preparedStatement.setString(3,student.getStudent_sex());
preparedStatement.setInt(4,student.getStudent_age());
preparedStatement.setInt(5,student.getStudent_state());
preparedStatement.setDouble(6,student.getStudent_credit());
preparedStatement.setString(7,student.getStudent_phone());
preparedStatement.setString(8,student.getStudent_address());
preparedStatement.setString(9,student.getStudent_qq());
preparedStatement.setString(10,student.getStudent_nation());
preparedStatement.setString(11,student.getStudent_dormitory_id());
preparedStatement.setString(12,student.getStudent_class_id());
preparedStatement.setString(13,student.getStudent_duty());
preparedStatement.setString(14,student.getStudent_enter_year());
preparedStatement.setString(15,student.getStudent_image_Path());
preparedStatement.setString(16,student.getStudent_id());
int i =preparedStatement.executeUpdate();
if(i==1)boo=true;
else boo=false;
} catch (SQLException e) {
e.printStackTrace();
}finally {
JdbcUtil.closeStatementAndResultSet(resultSet,preparedStatement);
JdbcUtil.closeConnection(conn);
}
return boo;
}
@Override//查询学生人数(class_id)
public int queryStudentSumByClass_id(String class_id) throws SQLException {
String sql = "SELECT count(*) FROM students WHERE student_class_id=?";
int sum = 0;
try {
preparedStatement = conn.prepareStatement(sql);
preparedStatement.setString(1, class_id);
resultSet = preparedStatement.executeQuery();
while (resultSet.next())
sum = resultSet.getInt(1);
} catch (SQLException e) {
e.printStackTrace();
} finally {
JdbcUtil.closeStatementAndResultSet(resultSet, preparedStatement);
JdbcUtil.closeConnection(conn);
}
return sum;
}
@Override //根据关键词查询学生后的总条目
public int queryStudentSumByKeywords(String keywords) throws SQLException {
String sql="SELECT DISTINCT count(*)\n" +
"FROM\n" +
"\tstudents\n" +
"WHERE\n" +
"\tstudent_id LIKE ? || stude
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
大学生创新创业训练计划-学生管理系统源码 (169个子文件)
bootstrap.min.css 118KB
foundation.min.css 106KB
skin.css 40KB
securityCenter.css 630B
studentManager.css 549B
scheduleTable.css 523B
index.css 396B
login.css 332B
translate.css 310B
register.css 247B
studentDetail.css 229B
bottom.css 128B
top.css 35B
videoLearn.css 0B
glyphicons-halflings-regular.eot 20KB
scheduleTable.ftl 2KB
studentManagement.iml 952B
poi-ooxml-schemas-3.16.jar 5.6MB
poi-3.16.jar 2.56MB
Sdk4J.jar 1.95MB
mysql-connector-java-8.0.11.jar 1.94MB
freemarker2.3.26.jar 1.43MB
poi-ooxml-3.16.jar 1.37MB
poi-scratchpad-3.16.jar 1.32MB
commons-collections-3.2.1.jar 562KB
mail.jar 496KB
standard-1.1.2.jar 384KB
poi-examples-3.16.jar 361KB
commons-lang-2.5.jar 273KB
junit-4.8.2.jar 232KB
commons-beanutils-1.8.0.jar 226KB
commons-io-2.5.jar 204KB
json-lib-2.4-jdk15.jar 155KB
javax.persistence.jar 127KB
aliyun-java-sdk-core-3.3.1.jar 105KB
commons-dbutils-1.7.jar 95KB
ezmorph-1.0.6.jar 84KB
javax.servlet.jsp.jar 77KB
commons-fileupload-1.3.2.jar 69KB
javax.servlet.jar 68KB
commons-logging-1.1.1.jar 59KB
activation.jar 55KB
javax.ejb.jar 46KB
javax.resource.jar 43KB
poi-excelant-3.16.jar 30KB
javax.jms.jar 25KB
jstl-1.0.6.jar 20KB
aliyun-java-sdk-dysmsapi-1.0.0.jar 18KB
javax.transaction.jar 9KB
baiduTranslate.jar 8KB
javax.annotation.jar 8KB
StudentDaoImpl.java 21KB
StudentServlet.java 18KB
Schedule.java 14KB
LoginServlet.java 13KB
ClassServlet.java 11KB
TeacherServlet.java 8KB
ClassDaoImpl.java 5KB
TeacherDaoImpl.java 5KB
Student.java 5KB
ScheduleDaoImpl.java 4KB
StudentServiceImpl.java 4KB
ValidateCodeUtil.java 4KB
ClassServiceImpl.java 4KB
SendSMSUtil.java 3KB
Teacher.java 3KB
InitServlet.java 3KB
LoginFilter.java 2KB
JdbcUtil.java 2KB
DormitoryDaoImpl.java 2KB
APIServlet.java 2KB
Class.java 2KB
StudentDao.java 2KB
Dormitory.java 2KB
ClassService.java 2KB
Utf_8Filter.java 2KB
Student_Leader.java 1KB
Student_simple.java 1KB
Bean_MapUtil.java 1KB
DeparmentDaoImpl.java 1KB
CookieUtil.java 1KB
Md5Util.java 939B
TeacherDao.java 855B
ClassDao.java 724B
Department.java 723B
TeacherServiceImpl.java 680B
ClassDaoImplTest.java 446B
DormitoryDao.java 408B
StudentService.java 390B
ScheduleDao.java 350B
TeacherServiceImplTest.java 259B
DeparmentDaoImplTest.java 247B
SMSCodeUtil.java 247B
TeacherService.java 242B
TeacherDaoImplTest.java 237B
DepartmentDao.java 233B
Test.java 127B
default.jpg 283KB
test1.jpg 93KB
teacher.jpg 74KB
共 169 条
- 1
- 2
资源评论
七夜zippoe
- 粉丝: 4742
- 资源: 133
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功