package dao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class userDao{
private Connection con = null;
private PreparedStatement ps = null;
static {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
private void prepareConnection() {
try {
if (con == null || con.isClosed()) {
con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/student?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true", "root", "123456");
}
} catch (SQLException e) {
throw new RuntimeException("###" + e.getMessage());
}
}
private void close() {
try {
if (ps != null) {
ps.close();
}
if (con != null) {
con.close();
}
} catch (SQLException e) {
throw new RuntimeException("?????????:" + e.getMessage());
}
}
private void rollback() {
try {
con.rollback();
} catch (SQLException e) {
throw new RuntimeException("??????:" + e.getMessage());
}
}
public boolean yzUser(sUser suser){
boolean val = false;
try {
prepareConnection();
ps = con.prepareStatement("select * from s_user ");
ResultSet rs = ps.executeQuery();
while (rs.next()) {
if(rs.getString(2).equals(suser.getS_word()) && rs.getString(3).equals(suser.getS_pass())){
val = true;
}
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
close();
}
return val;
}
public int zcUser(sUser suser){
int i =0;
try {
prepareConnection();
con.setAutoCommit(false);
String sql = "insert into s_user (s_word,s_pass,s_name,s_bj,s_xy) values(?,?,?,?,?)";
ps = con.prepareStatement(sql);
ps.setString(1, suser.getS_word());
ps.setString(2, suser.getS_pass());
ps.setString(3, suser.getS_name());
ps.setInt(4, suser.getS_bj());
ps.setString(5, suser.getS_xy());
i = ps.executeUpdate();
con.commit();
} catch (SQLException e) {
rollback();
e.printStackTrace();
}finally{
close();
}
return i;
}
public List<kUser> getAllkUser() {
List<kUser> kusers = new ArrayList<kUser>();
try {
prepareConnection();
ps = con.prepareStatement("select * from k_user ");
ResultSet rs = ps.executeQuery();
while (rs.next()) {
kUser kuser = new kUser();
kuser.setK_id(rs.getInt(1));
kuser.setK_kcm(rs.getString(2));
kuser.setK_js(rs.getString(3));
kuser.setK_jxl(rs.getInt(4));
kuser.setK_sj(rs.getString(5));
kuser.setK_xf(rs.getInt(6));
kusers.add(kuser);
// ?????????к??м???????????????????User????????????List??
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
close();
}
return kusers;
}
public kUser getkUserById(Integer id){
kUser kuser = null;
try {
prepareConnection();
ps = con.prepareStatement("select * from k_user where k_id=?");
ps.setInt(1, id);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
kuser = new kUser();
kuser.setK_id(rs.getInt(1));
kuser.setK_kcm(rs.getString(2));
kuser.setK_js(rs.getString(3));
kuser.setK_jxl(rs.getInt(4));
kuser.setK_sj(rs.getString(5));
kuser.setK_xf(rs.getInt(6));
// ?????????к??м???????????????????User????
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
close();
}
return kuser;
}
public Integer getNameByid(sUser suser){
Integer a = null;
try {
prepareConnection();
ps = con.prepareStatement("select * from s_user where s_word=?");
ps.setString(1, suser.getS_word());
ResultSet rs = ps.executeQuery();
if (rs.next()) {
a = rs.getInt(7);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
close();
}
return a;
}
public kUser getIdByKc(Integer a){
kUser kuser = null;
try {
prepareConnection();
ps = con.prepareStatement("select * from k_user where k_id=?");
ps.setInt(1, a);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
kuser = new kUser();
kuser.setK_id(rs.getInt(1));
kuser.setK_kcm(rs.getString(2));
kuser.setK_js(rs.getString(3));
kuser.setK_jxl(rs.getInt(4));
kuser.setK_sj(rs.getString(5));
kuser.setK_xf(rs.getInt(6));
// ?????????к??м???????????????????User????
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
close();
}
return kuser;
}
public kUser getkUserByName(String name){
kUser kuser = null;
try {
prepareConnection();
ps = con.prepareStatement("select * from k_user where k_kcm=?");
ps.setString(1, name);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
kuser = new kUser();
kuser.setK_id(rs.getInt(1));
kuser.setK_kcm(rs.getString(2));
kuser.setK_js(rs.getString(3));
kuser.setK_jxl(rs.getInt(4));
kuser.setK_sj(rs.getString(5));
kuser.setK_xf(rs.getInt(6));
// ?????????к??м???????????????????User????
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
close();
}
return kuser;
}
public int bcId(sUser suser) {
int i = 0;
try {
prepareConnection();
con.setAutoCommit(false);
ps = con
.prepareStatement("update s_user set s_xk=? where s_word=?");
ps.setInt(1, suser.getS_xk());
ps.setString(2, suser.getS_word());
i = ps.executeUpdate();
con.commit();
} catch (SQLException e) {
rollback();
e.printStackTrace();
} finally {
close();
}
return i;
}
public boolean adminUser(User user){
boolean val = false;
try {
prepareConnection();
ps = con.prepareStatement("select * from admin ");
ResultSet rs = ps.executeQuery();
while (rs.next()) {
if(rs.getString(2).equals(user.getU_word()) && rs.getString(3).equals(user.getU_pass())){
val = true;
}
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
close();
}
return val;
}
public int addkUser(kUser kuser) {
int i = 0;
try {
prepareConnection();
con.setAutoCommit(false);
ps = con.prepareStatement("insert into k_user (k_kcm,k_js,k_jxl,k_sj,k_xf) values(?,?,?,?,?)");
ps.setString(1, kuser.getK_kcm());
ps.setString(2, kuser.getK_js());
ps.setInt(3, kuser.getK_jxl());
ps.setString(4, kuser.getK_sj());
ps.setInt(5, kuser.getK_xf());
i = ps.executeUpdate();
con.commit();
} catch (SQLException e) {
rollback();
e.printStackTrace();
} finally {
close();
}
return i;
}
public int deletekUser(kUser kuser) {
int i = 0;
try {
prepareConnection();
con.setAutoCommit(false);
ps = con.prepareStatement("delete from k_user where k_id=?");
ps.setInt(1, kuser.getK_id());
i = ps.executeUpdate();
con.commit();
} catch (SQLException e) {
rollback();
e.printStackTrace();
} finally {
close();
}
return i;
}
public int updatekUser(kUser kuser) {
int i = 0;
try {
prepareConnection();
con.setAutoCommit(false);
ps = con.prepareStatement("update k_user set k_kcm=?,k_js=?,k_jxl=?,k_sj=?,k_xf=? where k_id=?");
ps.setString(1, kuser.getK_kcm());
ps.setString(2, kuser.getK_js());
ps.setInt(3, kuser.getK_jxl());
ps.setString(4, kuser.getK_sj());
ps.setInt(5, kuser.getK_xf());
ps.setInt(6, kuser.getK_id());
i = ps.executeUpdate();
con.commit();
} catch (SQLException e) {
rollback();
e.printStackTrace();
} finally {
close();
}
return i;
}
// public List<User> getAllUsers() {
// List<User> users = new ArrayList<User>();
// try {
// prepareConnection();
// ps = con.prepareStatement("select * from u_user ");
// ResultSet rs = ps.executeQuery();
// while (rs.next()) {
// User user = new User();
// user.setId(rs.getInt(1));
// user.setU_name(rs.getString(2));
// user.setU_age(rs.getInt(3));
// user.setU_sex(rs.getString(4));
// user.setU_xk(rs.getString(5));
// user.setU_fdy(rs.getString(
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
根据描述,这个系统不仅是选课系统,而是有其他教务管理和信息查询和维护的教务管理系统,选课系统只是这个教务管理系统的一个子系统。 使用教务管理系统的用户有三种,一种是学生,一种是任课教师,另外一种损失教务处的老师,可以认为是管理员,所以可以将用户也分为这三种,不同的用户登录到这个系统中要有不同的界面,不同的功能。 学生登录后有相关的信息查询和部分信息修改的权限,信息查询包括查询自己的个人信息,(自己的学号,班级,专业,籍贯,政治面貌,邮箱,联系方式等)选课信息(选了哪些课,课程表查看,每门课上课的时间,地点,任课教师,教学周起始等),成绩信息(查看自己的成绩信息,包括课程名称,分数,哪一个学期选修的这门课,任课教师等)。修改权限包括学生部分个人信息的修改(比如学生的联系电话,qq和微信,家庭住址,政治面貌等),在选课阶段修改自己的所选课程信息(在选课阶段,自由的增加选课和取消选课),修改自己的登录密码等。另外,仿照现有教务管理系统,增加私信老师的功能,使得学生可以向老师提交反馈,老师可以根据反馈进行相应的操作,学生可以不用打电话或者到教务处办公室寻求帮助。 任课教师登录后功能和学生不同,
资源推荐
资源详情
资源评论
收起资源包目录
源码.zip (93个子文件)
design
classes
artifacts
design_war_exploded
MyJsp.jsp 1KB
query.jsp 5KB
WEB-INF
classes
servlet
yzUser.class 3KB
chaxun.class 2KB
kcUser.class 4KB
demo.class 2KB
admin.class 4KB
dao
sUser.class 2KB
User.class 1KB
userDao.class 9KB
kUser.class 1KB
lib
mysql-connector-java-5.1.7-bin.jar 693KB
mysql-connector-java-8.0.21.jar 2.29MB
web.xml 3KB
index.jsp 4KB
home.jsp 8KB
js
bootstrap.min.js 35KB
jquery.min.js 94KB
admin.jsp 4KB
error.jsp 923B
img
005.jpg 50KB
008.jpg 5KB
win.jsp 948B
css
bootstrap.min.css 115KB
registered.jsp 5KB
background.jsp 9KB
META-INF
MANIFEST.MF 39B
fonts
glyphicons-halflings-regular.svg 106KB
glyphicons-halflings-regular.ttf 44KB
glyphicons-halflings-regular.woff 23KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.woff2 18KB
student.sql 4KB
.classpath 548B
src
servlet
admin.java 4KB
yzUser.java 3KB
demo.java 1KB
kcUser.java 3KB
chaxun.java 1KB
dao
kUser.java 907B
sUser.java 1KB
userDao.java 9KB
User.java 621B
design.iml 2KB
.idea
dataSources
2597d585-ef2c-46b9-98c4-693f59586f49.xml 30KB
2597d585-ef2c-46b9-98c4-693f59586f49
storage_v2
_src_
schema
performance_schema.kIw0nw.meta 76B
sys.zb4BAA.meta 61B
information_schema.FNRwLQ.meta 76B
mysql.osA4Bg.meta 63B
dataSources.local.xml 983B
sqldialects.xml 208B
artifacts
design_war_exploded.xml 799B
libraries
annotations_api.xml 2KB
jsp_api.xml 324B
workspace.xml 15KB
misc.xml 267B
dataSources.xml 608B
modules.xml 259B
.gitignore 285B
encodings.xml 323B
build
classes
servlet
yzUser.class 3KB
chaxun.class 2KB
kcUser.class 4KB
demo.class 2KB
admin.class 4KB
dao
sUser.class 2KB
User.class 1KB
userDao.class 9KB
kUser.class 1KB
WebContent
MyJsp.jsp 1KB
query.jsp 5KB
WEB-INF
lib
mysql-connector-java-5.1.7-bin.jar 693KB
mysql-connector-java-8.0.21.jar 2.29MB
web.xml 3KB
index.jsp 4KB
home.jsp 8KB
js
bootstrap.min.js 35KB
jquery.min.js 94KB
admin.jsp 4KB
error.jsp 923B
img
005.jpg 50KB
008.jpg 5KB
win.jsp 948B
css
bootstrap.min.css 115KB
registered.jsp 5KB
background.jsp 9KB
META-INF
MANIFEST.MF 39B
fonts
glyphicons-halflings-regular.svg 106KB
glyphicons-halflings-regular.ttf 44KB
glyphicons-halflings-regular.woff 23KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.woff2 18KB
.project 906B
共 93 条
- 1
资源评论
fswu
- 粉丝: 46
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- (源码)基于Quartz框架的定时任务调度系统.zip
- (源码)基于Spring Boot和Spring Security的安全管理系统.zip
- (源码)基于Spring Boot的家庭智能助理系统.zip
- Marki_20241121_192504660.jpg
- (源码)基于Spring Boot框架的仓库管理系统.zip
- (源码)基于Spring、Dubbo和MyBatis的跨境支付系统.zip
- (源码)基于Python的Excel数据处理系统.zip
- (源码)基于Python和ESP8266的物联网按钮通知系统.zip
- (源码)基于C++的多态职工管理系统.zip
- (源码)基于C++的小型便利店管理系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功