package com.kaoqin.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import com.kaoqin.db.Conn;
import com.kaoqin.po.Teacher;
public class TeacherDao {
public static boolean login(Teacher th){
Conn db = new Conn();
String sqlstr = "select id,userName,userPass,course from teacher where userName='" + th.getUserName() + "'";
ResultSet rs = db.executeQuery(sqlstr);
try {
if (rs != null && rs.next()) {
String pass = rs.getString("userPass");
if (th.getUserPass().equals(pass)) {
th.setId(rs.getInt("id"));
th.setCourse(rs.getString("course"));
return true;
}
}
} catch (SQLException ex) {
}
finally{
db.close();
}
return false;
}
public static boolean addTeacher(Teacher t){
Conn db = new Conn();
String sqlstr = "insert into teacher(userName,userPass,tname,tsex,office,remark) values('" +
t.getUserName() + "','" + t.getUserPass() + "','" + t.getTname() + "','" + t.getTsex() + "','" + t.getOffice() + "','" + t.getRemark() + "')";
System.out.println(sqlstr);
boolean flag = false;
if( db.executeUpdate(sqlstr) > 0) {
flag = true;
}
db.close();
return flag;
}
public static Vector<Teacher> getTeachers(){
Vector<Teacher> rows = new Vector<Teacher>();
Conn db = new Conn();
String sqlstr = "select id,userName,userPass,tname,tsex,office,remark from teacher";
System.out.println(sqlstr);
ResultSet rs = db.executeQuery(sqlstr);
try {
while(rs.next()) {
// rs.getInt("id");
// rs.getString("userName");
// rs.getString("userPass");
// rs.getString("tname");
// rs.getString("tsex");
// rs.getString("office");
// rs.getString("remark");
Teacher t = new Teacher(rs.getInt("id"),
rs.getString("userName"),
rs.getString("userPass"),
rs.getString("tname"),
rs.getString("tsex"),
rs.getString("office"),
rs.getString("remark"));
rows.add(t);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally{
try {
rs.close();
rs = null;
} catch (SQLException e) {
}
db.close();
}
return rows;
}
public static Teacher getTeacherById(String id){
Conn conn = new Conn();
String sqlstr = "select id,userName,userPass,tname,tsex,office,remark from teacher where id=" + id;
System.out.println(sqlstr);
Teacher t = null;
ResultSet rs = conn.executeQuery(sqlstr);
try {
if(rs.next()){
t = new Teacher(rs.getInt("id"),
rs.getString("userName"),
rs.getString("userPass"),
rs.getString("tname"),
rs.getString("tsex"),
rs.getString("office"),
rs.getString("remark"));
}
} catch (SQLException e) {
e.printStackTrace();
} finally{
conn.close();
}
return t;
}
public static boolean updateTeacher(Teacher t, String id){
Conn db = new Conn();
String sqlstr = "update teacher set userName='" + t.getUserName() +
"',userPass='" + t.getUserPass() +
"',tname='" + t.getTname() +
"',tsex='" + t.getTsex() +
"',office='" + t.getOffice() +
"',remark='" + t.getRemark() + "' where id=" + id;
System.out.println(sqlstr);
boolean flag = false;
if( db.executeUpdate(sqlstr) > 0) {
flag = true;
}
db.close();
return flag;
}
public static boolean delTeacher(String id){
Conn db = new Conn();
String sqlstr = "delete from teacher where id=" + id;
System.out.println(sqlstr);
boolean flag = false;
if( db.executeUpdate(sqlstr) > 0) {
flag = true;
}
db.close();
return flag;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
JSP+SQL学生考勤管理系统(毕业设计)
共220个文件
gif:152个
html:19个
jsp:18个
4星 · 超过85%的资源 需积分: 19 391 下载量 25 浏览量
2014-05-30
12:07:09
上传
评论 19
收藏 2.36MB RAR 举报
温馨提示
系统总体上由三大功能模块:请假系统模块、考勤系统模块、后台管理模块组成。系统涉及到高校三大类用户:学生、任课老师、系统管理员
资源推荐
资源详情
资源评论
收起资源包目录
JSP+SQL学生考勤管理系统(毕业设计) (220个子文件)
JSP学生考勤管理系统录像.avi 11.4MB
TeacherDao.class 4KB
Conn.class 3KB
StudentDao.class 3KB
EncondingFilter.class 2KB
QingJiaDao.class 1KB
AdminDao.class 1KB
KqTool.class 1KB
.classpath 552B
org.eclipse.wst.jsdt.ui.superType.container 49B
login_04.gif 23KB
error.gif 22KB
login_042.gif 20KB
login_041.gif 20KB
main_011.gif 14KB
main_011.gif 14KB
main_011.gif 14KB
main_01.gif 14KB
main_01.gif 14KB
main_01.gif 14KB
main_012.gif 13KB
main_012.gif 13KB
main_012.gif 13KB
login_11.gif 9KB
login_06.gif 5KB
login_10.gif 4KB
login_03.gif 4KB
main_07.gif 3KB
main_07.gif 3KB
main_07.gif 3KB
login_07.gif 3KB
login_08.gif 2KB
login_09.gif 2KB
main_11.gif 2KB
main_11.gif 2KB
main_11.gif 2KB
main_46.gif 1KB
main_46.gif 1KB
main_46.gif 1KB
main_40.gif 1KB
main_40.gif 1KB
main_40.gif 1KB
main_52.gif 1KB
main_52.gif 1KB
main_52.gif 1KB
main_50.gif 1KB
main_50.gif 1KB
main_50.gif 1KB
main_48.gif 1KB
main_48.gif 1KB
main_48.gif 1KB
main_05.gif 1KB
main_05.gif 1KB
main_05.gif 1KB
main_34_1.gif 1KB
main_34_1.gif 1KB
main_34_1.gif 1KB
main_34.gif 1KB
main_34.gif 1KB
main_34.gif 1KB
main_19.gif 1KB
main_19.gif 1KB
main_19.gif 1KB
main_06.gif 953B
main_06.gif 953B
main_06.gif 953B
main_03.gif 871B
main_03.gif 871B
main_03.gif 871B
dl.gif 813B
cz.gif 796B
main_29.gif 785B
main_29.gif 785B
main_29.gif 785B
main_13.gif 633B
main_13.gif 633B
main_13.gif 633B
main_17.gif 596B
user.gif 596B
main_17.gif 596B
user.gif 596B
main_17.gif 596B
user.gif 596B
main_15.gif 594B
main_15.gif 594B
main_15.gif 594B
main_21.gif 591B
main_21.gif 591B
main_21.gif 591B
main_10.gif 549B
main_10.gif 549B
main_10.gif 549B
main_58.gif 524B
main_58.gif 524B
main_58.gif 524B
main_56.gif 517B
main_56.gif 517B
main_56.gif 517B
main_60.gif 514B
main_60.gif 514B
共 220 条
- 1
- 2
- 3
shsj22
- 粉丝: 13
- 资源: 25
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页