资源简介
Java开发的教学资源管理系统。里面包含了教学资源管理系统的基本功能,能够直接运行。放心使用!
代码片段和文件信息
/***********************************************
/*
/*用户操作
/*
/******************************************* */
package com.admin;
import java.sql.*;
import java.util.ArrayList;
import com.util.*;
public class Admin {
public String adminid = ““;
public String pwd=““;
public String prelogin=““;
public String logintime=““;
public int totle=0;
public int id;
public Admin() {
}
//管理员登陆
public int login() throws Exception{
Connection conn=null;
PreparedStatement stmt =null;
ResultSet rs =null;
int flag=0;
String sql = “select * from admin where adminid=?“;
try{
conn =DBConn.getConn();
stmt =conn.prepareStatement(sql);
stmt.setString(1 adminid);
rs = stmt.executeQuery();
if(rs.next()){
sql=“select * from admin where adminid=? and pwd=?“;
stmt =conn.prepareStatement(sql);
stmt.setString(1 adminid);
stmt.setString(2 pwd);
rs = stmt.executeQuery();
if(rs.next()){
java.util.Date date=new java.util.Date();
Timestamp tt=new Timestamp(date.getTime());
if(rs.getInt(“totle“)==0){
sql=“update admin set totle=1logintime=? where adminid=?“;
stmt =conn.prepareStatement(sql);
stmt.setTimestamp(1 tt);
stmt.setString(2adminid);
stmt.executeUpdate();
}else{
sql=“update admin set totle=totle+1logintime=?prelogin=? where adminid=?“;
stmt =conn.prepareStatement(sql);
stmt.setTimestamp(1 tt);
stmt.setString(2rs.getString(“logintime“));
stmt.setString(3adminid);
stmt.executeUpdate();
}
flag=3;//登陆成功
}
else{
flag=2;//密码错误
}
}else{
flag=1;//不存在此管理员
}
}catch(Exception e){
e.printStackTrace();
}finally{
try{
if(rs!=null)
rs.close();
if(stmt!=null)
stmt.close();
if(conn!=null)
conn.close();
}catch(Exception ee){
ee.printStackTrace();
}
}
return flag;
}
//判断是否存在该管理员名称
public int isAdminExist() throws Exception{
Connection conn=null;
PreparedStatement stmt =null;
ResultSet rs =null;
int flag=0;
String sql = “select * from admin where adminid=?“;
try{
conn =DBConn.getConn();
stmt =conn.prepareStatement(sql);
stmt.setString(1 adminid);
rs = stmt.executeQuery();
if(rs.next()){
flag=1;//存在
}
else{
flag=2;//不存在
}
}catch(Exception e){
e.printStackTrace();
}finally{
try{
if(rs!=null)
rs.close();
if(s
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 102912 2006-03-07 15:47 第一章.ppt
----------- --------- ---------- ----- ----
102912 1
评论
共有 条评论