• 大小: 973KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-07
  • 语言: Java
  • 标签:

资源简介

基于java和sql的开发平台。易于理解。难度适中。

资源截图

代码片段和文件信息

package cn.kfu.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import cn.kfu.entity.AdminInfo;
import cn.kfu.entity.UserInfo;
import cn.kfu.util.DBUtil;

public class AdminInfoDAO {

public boolean searchUserInfo(AdminInfo u) {
boolean result=false;
Connection conn = DBUtil.getConnection();
String sql = “select * from adminInfo where userName=? and password=?“;
try {
PreparedStatement pstm = conn.prepareStatement(sql);
pstm.setString(1 u.getUserName());
pstm.setString(2 u.getPassword());
ResultSet rs=pstm.executeQuery();
if(rs.next()){
result=true;
}
if(rs!=null)rs.close();
if(pstm!=null)pstm.close();
if(conn!=null)DBUtil.close(conn);

} catch (SQLException e) {
e.printStackTrace();
}
return result;
}

public ArrayList selectAll() {
        ArrayList arr = null;
Connection conn = DBUtil.getConnection();
String sql = “select * from userinfo“;
try {
Statement stm = conn.createStatement();
ResultSet rs = stm.executeQuery(sql);
arr = new ArrayList();
while(rs.next()){
UserInfo a = new UserInfo();
a.setUsername(rs.getString(1));
a.setPassword(rs.getString(2));
arr.add(a);
}
if(rs!=null)rs.close();
if(stm!=null)stm.close();
if(conn!=null)DBUtil.close(conn);
} catch (SQLException e) {
e.printStackTrace();
}
return arr;
}

public boolean update(String passwordString username) {
Connection conn = DBUtil.getConnection();
String sql = “update adminInfo set password=? where userName=?“;
boolean result=false;
try {
PreparedStatement pstm = conn.prepareStatement(sql);
    pstm.setString(1 password);
    pstm.setString(2 username);
    int i=pstm.executeUpdate();
    if(i>0){
     result=true;
    }
if(pstm!=null)pstm.close();
if(conn!=null)DBUtil.close(conn);
} catch (SQLException e) {
e.printStackTrace();
}
return result;
}
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2011-05-06 08:47  BookShop\
     文件         492  2011-04-19 16:47  BookShop\.classpath
     目录           0  2011-05-06 08:47  BookShop\.metadata\
     文件           0  2011-04-26 15:51  BookShop\.metadata\.lock
     文件        2846  2011-04-26 15:51  BookShop\.metadata\.log
     目录           0  2011-05-06 08:47  BookShop\.metadata\.plugins\
     目录           0  2011-05-06 08:47  BookShop\.metadata\.plugins\com.genuitec.eclipse.hibernate\
     目录           0  2011-05-06 08:47  BookShop\.metadata\.plugins\com.genuitec.org.hibernate.eclipse\
     文件           0  2011-04-26 15:51  BookShop\.metadata\.plugins\com.genuitec.org.hibernate.eclipse\hibernate-tools.log
     目录           0  2011-05-06 08:47  BookShop\.metadata\.plugins\org.eclipse.core.resources\
     目录           0  2011-05-06 08:47  BookShop\.metadata\.plugins\org.eclipse.core.resources\.history\
     目录           0  2011-05-06 08:47  BookShop\.metadata\.plugins\org.eclipse.core.resources\.root\
     目录           0  2011-05-06 08:47  BookShop\.metadata\.plugins\org.eclipse.core.resources\.root\.indexes\
     文件           1  2011-04-26 15:52  BookShop\.metadata\.plugins\org.eclipse.core.resources\.root\.indexes\history.version
     文件          57  2011-04-26 15:51  BookShop\.metadata\.plugins\org.eclipse.core.resources\.root\.indexes\properties.index
     文件           1  2011-04-26 15:52  BookShop\.metadata\.plugins\org.eclipse.core.resources\.root\.indexes\properties.version
     文件          77  2011-04-26 15:52  BookShop\.metadata\.plugins\org.eclipse.core.resources\.root\1.tree
     目录           0  2011-05-06 08:47  BookShop\.metadata\.plugins\org.eclipse.core.resources\.safetable\
     文件         319  2011-04-26 15:52  BookShop\.metadata\.plugins\org.eclipse.core.resources\.safetable\org.eclipse.core.resources
     目录           0  2011-05-06 08:47  BookShop\.metadata\.plugins\org.eclipse.core.runtime\
     目录           0  2011-05-06 08:47  BookShop\.metadata\.plugins\org.eclipse.core.runtime\.settings\
     文件         104  2011-04-26 15:51  BookShop\.metadata\.plugins\org.eclipse.core.runtime\.settings\com.genuitec.eclipse.easie.bejy.prefs
     文件         104  2011-04-26 15:51  BookShop\.metadata\.plugins\org.eclipse.core.runtime\.settings\com.genuitec.eclipse.easie.core.prefs
     文件         104  2011-04-26 15:51  BookShop\.metadata\.plugins\org.eclipse.core.runtime\.settings\com.genuitec.eclipse.easie.geronimo1.prefs
     文件         104  2011-04-26 15:51  BookShop\.metadata\.plugins\org.eclipse.core.runtime\.settings\com.genuitec.eclipse.easie.jboss.prefs
     文件         104  2011-04-26 15:51  BookShop\.metadata\.plugins\org.eclipse.core.runtime\.settings\com.genuitec.eclipse.easie.jboss2.prefs
     文件         104  2011-04-26 15:51  BookShop\.metadata\.plugins\org.eclipse.core.runtime\.settings\com.genuitec.eclipse.easie.jboss3.prefs
     文件         104  2011-04-26 15:51  BookShop\.metadata\.plugins\org.eclipse.core.runtime\.settings\com.genuitec.eclipse.easie.jboss4.prefs
     文件         104  2011-04-26 15:51  BookShop\.metadata\.plugins\org.eclipse.core.runtime\.settings\com.genuitec.eclipse.easie.jetty.prefs
     文件         104  2011-04-26 15:51  BookShop\.metadata\.plugins\org.eclipse.core.runtime\.settings\com.genuitec.eclipse.easie.jetty4.prefs
     文件         104  2011-04-26 15:51  BookShop\.metadata\.plugins\org.eclipse.core.runtime\.settings\com.genuitec.eclipse.easie.jetty5.prefs
............此处省略297个文件信息

评论

共有 条评论