• 大小: 60KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-11
  • 语言: Java
  • 标签: 信息管理  

资源简介

这个是 J2EE 的学生信息管理系统 做的很简单 但是 登录,增加,删除,修改,查找等功能是有的。希望你看后会有所收获

资源截图

代码片段和文件信息


package dao;

import java.sql.*;
import java.util.ArrayList;
import java.util.List;

import model.Admin;
import model.Student;

import util.DB;

public class AdminDao {
 Connection con=null;
 Statement stmt=null;
 ResultSet rs=null;
 PreparedStatement ps=null;
// 查询主键是否已存在
public  int count(String condition){
ResultSet rs=null;
con=DB.getConnection();
int c=0;
try {
stmt=con.createStatement();
rs=stmt.executeQuery(“select count(*) from admin “+condition);
rs.next();
c=rs.getInt(1);
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}

DB.close(rs);
DB.close(stmt);
DB.close(con);
return c;
}
public  boolean isExist(String id){
ResultSet rs=null;
con=DB.getConnection();
try {
stmt=con.createStatement();
rs=stmt.executeQuery(“select * from admin where id = ‘“+id+“‘“);
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
boolean yes=true;
try {
while(rs.next()){
yes=false;
}
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
DB.close(rs);
DB.close(stmt);
DB.close(con);
return yes;
}
//查询
public  Admin quaryById(String id){
ResultSet rs=null;
Admin s=null;
con=DB.getConnection();
try {
stmt=con.createStatement();
rs=stmt.executeQuery(“select * from admin where id = ‘“+id+“‘“);
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
try {
if(rs.next()){
s=new Admin();
s.setId(rs.getString(1));
s.setName(rs.getString(2));
s.setPassword(rs.getString(3));

}
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
DB.close(rs);
DB.close(stmt);
DB.close(con);
return s;
}
public  List quary(String sql){
ResultSet rs=null;
List list=new ArrayList();
con=DB.getConnection();
try {
stmt=con.createStatement();
rs=stmt.executeQuery(sql);
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
try {
while(rs.next()){
Admin s=new Admin();
s.setId(rs.getString(1));
s.setName(rs.getString(2));
s.setPassword(rs.getString(3));

list.add(s);
}
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
DB.close(rs);
DB.close(stmt);
DB.close(con);
return list;
}
//插入
public  int insert(Admin s){
con=DB.getConnection();
int i=0;
try {
ps=con.prepareStatement(“insert into admin values (???)“);
ps.setString(1 s.getId());
ps.setString(2 s.getName());
ps.setString(3 s.getPassword());
i=ps.executeUpdate();
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
DB.close(ps);
DB.close(con);
return i;
}

//删除
public  int delete(Admin s){
con=DB.getConnection();
int i=0;
try {
ps=con.prepareSt

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-05-20 10:47  week11_studentsystem\
     文件         362  2013-04-17 01:07  week11_studentsystem\.classpath
     目录           0  2013-05-20 10:47  week11_studentsystem\.myeclipse\
     文件         334  2014-07-01 12:42  week11_studentsystem\.mymetadata
     文件        1426  2013-05-15 09:01  week11_studentsystem\.project
     目录           0  2013-05-20 10:47  week11_studentsystem\.settings\
     文件         500  2013-04-17 01:07  week11_studentsystem\.settings\.jsdtscope
     文件        1040  2013-04-17 01:07  week11_studentsystem\.settings\com.genuitec.eclipse.j2eedt.core.prefs
     文件         330  2013-04-17 01:07  week11_studentsystem\.settings\org.eclipse.jdt.core.prefs
     文件          49  2013-04-17 01:07  week11_studentsystem\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2013-04-17 01:07  week11_studentsystem\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2013-05-20 10:47  week11_studentsystem\database\
     文件        2068  2013-05-15 09:31  week11_studentsystem\database\stu.sql
     文件      225280  2013-04-17 01:07  week11_studentsystem\database\student.mdb
     目录           0  2013-05-20 10:47  week11_studentsystem\src\
     目录           0  2013-05-20 10:47  week11_studentsystem\src\dao\
     文件        4061  2013-05-13 08:24  week11_studentsystem\src\dao\AdminDao.java
     文件        4188  2013-05-15 09:37  week11_studentsystem\src\dao\StudentDao.java
     目录           0  2013-05-20 10:47  week11_studentsystem\src\filter\
     文件         950  2013-05-06 09:54  week11_studentsystem\src\filter\EncodingFitler.java
     文件        1136  2013-05-15 11:58  week11_studentsystem\src\filter\UserFilter.java
     目录           0  2013-05-20 10:47  week11_studentsystem\src\model\
     文件         456  2013-05-13 08:11  week11_studentsystem\src\model\Admin.java
     文件         555  2013-05-15 09:34  week11_studentsystem\src\model\Student.java
     目录           0  2013-05-20 10:47  week11_studentsystem\src\servlet\
     目录           0  2013-05-20 10:47  week11_studentsystem\src\servlet\admin\
     文件        2213  2013-05-15 10:18  week11_studentsystem\src\servlet\admin\Delete.java
     文件        2912  2013-05-15 10:19  week11_studentsystem\src\servlet\admin\Insert.java
     文件        2291  2013-05-15 10:19  week11_studentsystem\src\servlet\admin\Update.java
     文件        1957  2013-05-13 09:06  week11_studentsystem\src\servlet\Exit.java
     文件        3472  2013-05-15 11:01  week11_studentsystem\src\servlet\Login.java
............此处省略46个文件信息

评论

共有 条评论