• 大小: 8.53MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-10-10
  • 语言: Java
  • 标签: java  

资源简介

java web完整购物系统

资源截图

代码片段和文件信息

package szy.shopping.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import szy.shopping.entity.Admin;

public class AdminDAO {
Connection con;
PreparedStatement pstm;
ResultSet rs;

public AdminDAO(){
Initialization initialization=new Initialization();
con=initialization.init();
}
//查询管理员密码是否正确
public boolean checkAdmin(Admin admin){
boolean result=false;
try {
pstm=con.prepareStatement(“select * from Admin where userName=? and password=?“);
pstm.setobject(1 admin.getUserName());
pstm.setobject(2 admin.getPassword());
rs=pstm.executeQuery();
if(rs.next())  //存在结果
result=true;
destroy();
} catch (Exception e) {
System.err.println(“AdminDAO.checkAdmin ERROR ## “+e.getMessage());
}
return result;
}
//修改密码
public boolean changePassword(String userNameString newPassword){
boolean result=false;
try {
pstm=con.prepareStatement(“update admin set password=? where userName=?“);
pstm.setobject(1 newPassword);
pstm.setobject(2 userName);
pstm.execute();
result=true;
destroy();
} catch (Exception e) {
System.err.println(“AdminDAO.changePassword ERROR ## “+e.getMessage());
}
return result;

//添加新客户
public boolean addNewAdmin(Admin admin){
boolean result=false;
try {
pstm=con.prepareStatement(“insert into Admin values(??)“);
pstm.setobject(1 admin.getUserName());
pstm.setobject(2 admin.getPassword());
pstm.execute();
result=true;
destroy();
} catch (Exception e) {
System.err.println(“AdminDAO.addNewAdmin ERROR ## “+e.getMessage());
}
return result;
}

//释放资源
private void destroy(){
try {
if(rs!=null){
rs.close();
}
if(pstm!=null){
pstm.close();
}
if(con!=null){
con.close();
}
} catch (Exception e) {
System.out.println(“CustomerDAO.destroy ERROR ## “+e.getMessage());
}
}
//
// public static void main(String[] args) {
// //AdminDAO admin=new AdminDAO();
// //System.out.println(admin.checkAdmin(“admin“ “admin“));
// //System.out.println(admin.changePassword(“admin“ “admin“));
// //System.out.println(admin.addNewAdmin(“coolszy“ “kuka“));
// }

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-10-04 09:38  shopping\
     文件         843  2014-09-21 16:05  shopping\.classpath
     文件        1183  2014-09-21 16:06  shopping\.project
     目录           0  2014-10-04 09:30  shopping\.settings\
     文件         454  2009-05-04 21:19  shopping\.settings\.jsdtscope
     文件          80  2014-09-21 16:05  shopping\.settings\com.genuitec.eclipse.migration.prefs
     文件         330  2009-05-04 21:19  shopping\.settings\org.eclipse.jdt.core.prefs
     文件         422  2009-05-04 21:19  shopping\.settings\org.eclipse.wst.common.component
     文件         323  2014-09-21 16:05  shopping\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2009-05-04 21:19  shopping\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2009-05-04 21:19  shopping\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2014-10-04 09:30  shopping\build\
     目录           0  2014-10-04 09:30  shopping\build\classes\
     文件        1363  2009-05-29 15:35  shopping\build\classes\displaytag_zh_CN.properties
     目录           0  2014-10-04 09:30  shopping\build\classes\szy\
     目录           0  2014-10-04 09:30  shopping\build\classes\szy\shopping\
     目录           0  2014-10-04 09:30  shopping\build\classes\szy\shopping\dao\
     文件        2913  2014-10-01 09:40  shopping\build\classes\szy\shopping\dao\AdminDAO.class
     文件        4865  2014-10-01 09:40  shopping\build\classes\szy\shopping\dao\CustomerDAO.class
     文件        7696  2014-10-01 09:40  shopping\build\classes\szy\shopping\dao\GoodsDAO.class
     文件        1305  2014-10-01 09:40  shopping\build\classes\szy\shopping\dao\Initialization.class
     文件        3132  2014-10-01 09:40  shopping\build\classes\szy\shopping\dao\MessageDAO.class
     文件        4461  2014-10-01 09:40  shopping\build\classes\szy\shopping\dao\OrderFormDAO.class
     文件        6218  2014-10-01 09:40  shopping\build\classes\szy\shopping\dao\ShoppingCarDAO.class
     目录           0  2014-10-04 09:30  shopping\build\classes\szy\shopping\entity\
     文件        1113  2014-10-01 09:40  shopping\build\classes\szy\shopping\entity\Admin.class
     文件        1450  2014-10-01 09:40  shopping\build\classes\szy\shopping\entity\CarGoodsDetails.class
     文件        1632  2014-10-01 09:40  shopping\build\classes\szy\shopping\entity\Customer.class
     文件        2174  2014-10-01 09:40  shopping\build\classes\szy\shopping\entity\Goods.class
     文件        1870  2014-10-01 09:40  shopping\build\classes\szy\shopping\entity\Message.class
     文件        1247  2014-10-01 09:40  shopping\build\classes\szy\shopping\entity\OrderForm.class
............此处省略332个文件信息

评论

共有 条评论