• 大小: 49KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-07-11
  • 语言: Java
  • 标签: J2EE  mySQL  

资源简介

JSP学生信息管理系统,有数据库,代码详细,分为管理员和学生两个部分。

资源截图

代码片段和文件信息


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

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        362  2013-04-17 01:07  week11_studentsystem\.classpath

     文件        334  2013-05-15 09:02  week11_studentsystem\.mymetadata

     文件       1426  2013-05-15 09:01  week11_studentsystem\.project

     文件        847  2013-05-06 11:05  week11_studentsystem\WebRoot\error.jsp

     文件       1989  2013-05-15 12:03  week11_studentsystem\WebRoot\login.jsp

     文件       2021  2013-05-15 10:28  week11_studentsystem\WebRoot\regist.jsp

     文件       3833  2013-05-15 12:03  week11_studentsystem\WebRoot\WEB-INF\web.xml

     文件       1544  2013-05-15 09:01  week11_studentsystem\WebRoot\WEB-INF\classes\util\DB.class

     文件       1720  2013-05-15 09:01  week11_studentsystem\WebRoot\WEB-INF\classes\util\DB2.class

     文件       1321  2013-05-15 09:01  week11_studentsystem\WebRoot\WEB-INF\classes\servlet\Exit.class

     文件       2749  2013-05-15 11:01  week11_studentsystem\WebRoot\WEB-INF\classes\servlet\Login.class

     文件       2782  2013-05-15 10:30  week11_studentsystem\WebRoot\WEB-INF\classes\servlet\student\Regist.class

     文件       1761  2013-05-15 10:18  week11_studentsystem\WebRoot\WEB-INF\classes\servlet\admin\Delete.class

     文件       2036  2013-05-15 10:19  week11_studentsystem\WebRoot\WEB-INF\classes\servlet\admin\Insert.class

     文件       1796  2013-05-15 10:19  week11_studentsystem\WebRoot\WEB-INF\classes\servlet\admin\Update.class

     文件        872  2013-05-15 09:01  week11_studentsystem\WebRoot\WEB-INF\classes\model\Admin.class

     文件       1077  2013-05-15 09:34  week11_studentsystem\WebRoot\WEB-INF\classes\model\Student.class

     文件       1399  2013-05-15 09:01  week11_studentsystem\WebRoot\WEB-INF\classes\filter\EncodingFitler.class

     文件       1689  2013-05-15 11:58  week11_studentsystem\WebRoot\WEB-INF\classes\filter\UserFilter.class

     文件       4460  2013-05-15 09:01  week11_studentsystem\WebRoot\WEB-INF\classes\dao\AdminDao.class

     文件       4625  2013-05-15 09:37  week11_studentsystem\WebRoot\WEB-INF\classes\dao\StudentDao.class

     文件       1207  2013-05-15 11:28  week11_studentsystem\WebRoot\student\index.jsp

     文件        848  2013-05-15 09:52  week11_studentsystem\WebRoot\student\modifypassword.jsp

     文件        840  2013-05-15 09:51  week11_studentsystem\WebRoot\student\update.jsp

     文件        412  2013-04-17 01:07  week11_studentsystem\WebRoot\meta-INF\context.xml

     文件         36  2013-04-17 01:07  week11_studentsystem\WebRoot\meta-INF\MANIFEST.MF

     文件       4467  2013-05-15 11:00  week11_studentsystem\WebRoot\admin\index.jsp

     文件       2042  2013-05-13 08:55  week11_studentsystem\WebRoot\admin\insertform.jsp

     文件       2471  2013-05-15 09:43  week11_studentsystem\WebRoot\admin\updateform.jsp

     文件       1371  2013-04-17 01:07  week11_studentsystem\src\util\DB.java

............此处省略50个文件信息

评论

共有 条评论