资源简介
这是一个小型的电子商务网站适用于个人建站作为模板用。也可作为计算机类学生课程设计作品用
代码片段和文件信息
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“));
// }
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1769 2011-11-14 20:20 shopping+jsp\.classpath
文件 297 2011-11-22 14:06 shopping+jsp\.myme
文件 1414 2011-11-22 14:06 shopping+jsp\.project
文件 406 2011-11-22 14:06 shopping+jsp\.settings\.jsdtscope
文件 49 2011-11-22 14:06 shopping+jsp\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2011-11-22 14:06 shopping+jsp\.settings\org.eclipse.wst.jsdt.ui.superType.name
文件 1363 2009-05-29 15:35 shopping+jsp\src\displaytag_zh_CN.properties
文件 2306 2009-05-31 14:34 shopping+jsp\src\szy\shopping\dao\AdminDAO.java
文件 3834 2009-05-31 14:35 shopping+jsp\src\szy\shopping\dao\CustomerDAO.java
文件 7676 2009-05-31 14:35 shopping+jsp\src\szy\shopping\dao\GoodsDAO.java
文件 544 2009-05-24 19:58 shopping+jsp\src\szy\shopping\dao\Initialization.java
文件 2215 2009-05-31 14:35 shopping+jsp\src\szy\shopping\dao\MessageDAO.java
文件 2834 2009-05-31 14:35 shopping+jsp\src\szy\shopping\dao\OrderFormDAO.java
文件 5967 2009-05-31 14:35 shopping+jsp\src\szy\shopping\dao\ShoppingCarDAO.java
文件 663 2009-05-18 18:28 shopping+jsp\src\szy\shopping\entity\Admin.java
文件 1039 2009-05-13 20:13 shopping+jsp\src\szy\shopping\entity\CarGoodsDetails.java
文件 1363 2009-05-25 18:48 shopping+jsp\src\szy\shopping\entity\Customer.java
文件 1805 2009-05-13 20:04 shopping+jsp\src\szy\shopping\entity\Goods.java
文件 1408 2009-05-28 15:27 shopping+jsp\src\szy\shopping\entity\Message.java
文件 751 2009-05-30 13:20 shopping+jsp\src\szy\shopping\entity\OrderForm.java
文件 1042 2009-05-13 21:06 shopping+jsp\src\szy\shopping\entity\OrderFormDetails.java
文件 1099 2011-11-14 20:22 shopping+jsp\src\szy\shopping\filter\AdminFilter.java
文件 414 2009-05-29 23:09 shopping+jsp\src\szy\shopping\otherclasses\ChangeEncoding.java
文件 1997 2009-05-30 11:58 shopping+jsp\src\szy\shopping\services\AdminService.java
文件 4166 2009-05-30 14:28 shopping+jsp\src\szy\shopping\services\CustomerServices.java
文件 1079 2009-05-28 16:27 shopping+jsp\src\szy\shopping\services\GoodsServices.java
文件 2375 2009-06-06 14:29 shopping+jsp\src\szy\shopping\servlet\admin\AddCustomerServlet.java
文件 4646 2009-05-30 16:29 shopping+jsp\src\szy\shopping\servlet\admin\AddGoodsServlet.java
文件 1921 2009-05-30 11:51 shopping+jsp\src\szy\shopping\servlet\admin\AddNewManagerServlet.java
文件 2350 2009-05-30 12:17 shopping+jsp\src\szy\shopping\servlet\admin\ChangePasswordServlet.java
............此处省略330个文件信息
评论
共有 条评论