资源简介
基于javaweb的在线客户信息管理,主要实现了客户信息的增删改查基本功能,其中涉及到java,html,jsp,javascript,servlet,jquery,filter,session等等
代码片段和文件信息
package com.atsjp.webDemo.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.linkedList;
import java.util.List;
import com.atsjp.webDemo.daoInter.CustomerDaoInter;
import com.atsjp.webDemo.entity.Customer;
import com.atsjp.webDemo.utils.JDBC;
public class CustomerDao implements CustomerDaoInter {
private Connection conn = JDBC.getConnection();
private PreparedStatement ps = null;
private ResultSet res = null;
/*
*
* 增加customer对象
*/
@Override
public boolean addCustomer(Customer customer) {
try {
String sql = “select * from customers where cname = ?“;
ps = conn.prepareStatement(sql);
ps.setString(1 customer.getCname());
res = ps.executeQuery();
if (res.next()) { // 存在相同用户名,
return false;
}
sql = “select * from customers where cphone = ?“;
ps = conn.prepareStatement(sql);
ps.setString(1 customer.getCphone());
res = ps.executeQuery();
if (res.next()) {// 存在相同手机号码,
return false;
} else {
String sql1 = “insert into customers values(?????????)“;
ps = conn.prepareStatement(sql1);
ps.setString(1 customer.getId());
ps.setString(2 customer.getCname());
ps.setString(3 customer.getCpassword());
ps.setString(4 customer.getCgender());
ps.setString(5 customer.getCbirth());
ps.setString(6 customer.getCmajority());
ps.setString(7 customer.getCinterest());
ps.setString(8 customer.getCemail());
ps.setString(9 customer.getCphone());
ps.executeUpdate();
return true;
}
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
/*
*
* 删除customer对象
*/
@Override
public boolean deleteCustomer(Customer customer) {
String sql = “delete from customers where cname=?“;
try {
ps = conn.prepareStatement(sql);
ps.setString(1 customer.getCname());
ps.executeUpdate();
return true;
} catch (Exception e) {
return false;
}
}
/*
*
* 修改customer对象
*/
@Override
public boolean modifyCustomer(Customer customer) {
String sql = “update customers set cname=?cpassword=?cgender=?cbirth=?cmajority=?cinterest=?cemail=?cphone=? where id=?“;
try {
ps = conn.prepareStatement(sql);
ps.setString(1 customer.getCname());
ps.setString(2 customer.getCpassword());
ps.setString(3 customer.getCgender());
ps.setString(4 customer.getCbirth());
ps.setString(5 customer.getCmajority());
ps.setString(6 customer.getCinterest());
ps.setString(7 customer.getCemail());
ps.setString(8 customer.getCphone());
ps.setString(9 customer.getId());
ps.executeUpdate();
return true;
} catch (Exception e) {
return false;
}
}
/*
*
* 根据返回的customer对象的cname或者cphone,查找customer对象
*/
@Override
public Customer getCustomer(Customer customer) {
C
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-08-15 22:15 webDemo\
文件 851 2017-08-15 22:15 webDemo\.classpath
文件 1040 2017-08-15 22:15 webDemo\.project
目录 0 2017-08-15 22:15 webDemo\.settings\
文件 503 2017-08-15 22:15 webDemo\.settings\.jsdtscope
文件 115 2017-08-15 22:15 webDemo\.settings\org.eclipse.core.resources.prefs
文件 364 2017-08-15 22:15 webDemo\.settings\org.eclipse.jdt.core.prefs
文件 473 2017-08-15 22:15 webDemo\.settings\org.eclipse.wst.common.component
文件 305 2017-08-15 22:15 webDemo\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2017-08-15 22:15 webDemo\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2017-08-15 22:15 webDemo\.settings\org.eclipse.wst.jsdt.ui.superType.name
目录 0 2017-08-15 22:15 webDemo\build\
目录 0 2017-08-15 22:15 webDemo\build\classes\
目录 0 2017-08-15 22:15 webDemo\build\classes\com\
目录 0 2017-08-15 22:15 webDemo\build\classes\com\atsjp\
目录 0 2017-08-15 22:15 webDemo\build\classes\com\atsjp\webDemo\
目录 0 2017-08-15 22:15 webDemo\build\classes\com\atsjp\webDemo\dao\
目录 0 2017-08-15 22:15 webDemo\build\classes\com\atsjp\webDemo\daoInter\
文件 493 2017-08-15 22:15 webDemo\build\classes\com\atsjp\webDemo\daoInter\CustomerDaoInter.class
文件 314 2017-08-15 22:15 webDemo\build\classes\com\atsjp\webDemo\daoInter\UserDaoInter.class
文件 5139 2017-08-15 22:15 webDemo\build\classes\com\atsjp\webDemo\dao\CustomerDao.class
文件 2963 2017-08-15 22:15 webDemo\build\classes\com\atsjp\webDemo\dao\Userdao.class
目录 0 2017-08-15 22:15 webDemo\build\classes\com\atsjp\webDemo\entity\
文件 2963 2017-08-15 22:15 webDemo\build\classes\com\atsjp\webDemo\entity\Customer.class
文件 2159 2017-08-15 22:15 webDemo\build\classes\com\atsjp\webDemo\entity\Page.class
文件 1634 2017-08-15 22:15 webDemo\build\classes\com\atsjp\webDemo\entity\User.class
目录 0 2017-08-15 22:15 webDemo\build\classes\com\atsjp\webDemo\filter\
文件 2100 2017-08-15 22:15 webDemo\build\classes\com\atsjp\webDemo\filter\LoginFilter.class
目录 0 2017-08-15 22:15 webDemo\build\classes\com\atsjp\webDemo\service\
文件 2726 2017-08-15 22:15 webDemo\build\classes\com\atsjp\webDemo\service\UserService.class
目录 0 2017-08-15 22:15 webDemo\build\classes\com\atsjp\webDemo\servlet\
............此处省略69个文件信息
评论
共有 条评论