• 大小: 5.32MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-09-16
  • 语言: Java
  • 标签: JavaWeb  Servlet  jsp  

资源简介

使用Servlet JSP实现,并没有使用框架。

资源截图

代码片段和文件信息

package dao;

import cn.itcast.jdbc.TxQueryRunner;
import domain.Customer;
import domain.PageBean;
import org.apache.commons.collections.buffer.CircularFifoBuffer;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.apache.commons.dbutils.handlers.ScalarHandler;

import java.util.ArrayList;
import java.util.List;
import java.util.spi.CurrencyNameProvider;

/**
 * Created by codingBoy on 16/10/23.
 */
public class CustomerDao
{
    private QueryRunner qr=new TxQueryRunner();

    public void add(Customer c)
    {
        try {
            String sql = “insert into t_customer values(??????)“;
            object[] params = {c.getId() c.getName() c.getGender()
                    c.getPhone() c.getEmail() c.getDescription()};

            qr.update(sql params);
        }catch (Exception e)
        {
            throw new RuntimeException(e);
        }
    }

//    public List findAll()
//    {
//        try{
//            String sql=“select * from t_customer“;
//            return qr.query(sqlnew BeanListHandler(Customer.class));
//        }catch (Exception e)
//        {
//            throw new RuntimeException(e);
//        }
//    }
    public PageBean findAll(int pc int pr)
    {
        try{
            /*
             *1.他需要创建pageBean对象pb
             * 2.设置pb的pc和pr
             * 3.得到tr,设置给pb
             * 4.得到beanList设置给pb
             * 最后返回给pb
             */
            PageBean pb=new PageBean<>();
            pb.setPc(pc);
            pb.setPr(pr);

            String sql=“select count(*) from t_customer“;
            Number number=(Number) qr.query(sqlnew ScalarHandler<>());

            int tr=number.intValue();
            pb.setTr(tr);

            sql=“select * from t_customer order by name limit ??“;
            object[] params={(pc-1)*prpr};
            List beanList=qr.query(sqlnew BeanListHandler<>(Customer.class)params);

            pb.setBeanList(beanList);

            return pb;
        }catch (Exception e)
        {
            throw new RuntimeException(e);
        }
    }

    public Customer find(String id)
    {
        try {
            String sql = “select * from t_customer where id=?“;
            return qr.query(sql new BeanHandler(Customer.class) id);
        }catch (Exception e)
        {
            throw new RuntimeException(e);
        }
    }

    public void edit(Customer customer)
    {
        try{
            String sql=“update t_customer set name=?gender=?phone=?email=?description=? where id=?“;
            object[] params={customer.getName()customer.getGender()customer.getPhone()customer.getEmail()customer.getDescription()customer.getId()};

            qr.update(sqlparams);
        }catch (Exception e)
        {
            throw new RuntimeException(e);
        }
    }

    public void delete

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-04-06 07:48  CustomerManagement-master\
     文件        1425  2017-04-06 07:48  CustomerManagement-master\CustomerManagement.iml
     文件        2148  2017-04-06 07:48  CustomerManagement-master\README.md
     目录           0  2017-04-06 07:48  CustomerManagement-master\out\
     目录           0  2017-04-06 07:48  CustomerManagement-master\out\artifacts\
     目录           0  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\
     目录           0  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\
     目录           0  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\classes\
     目录           0  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\classes\Demo\
     文件        1429  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\classes\Demo\Demo.class
     文件         578  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\classes\c3p0-config.xml
     目录           0  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\classes\dao\
     文件        5251  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\classes\dao\CustomerDao.class
     目录           0  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\classes\domain\
     文件        1450  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\classes\domain\Customer.class
     文件        1919  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\classes\domain\PageBean.class
     目录           0  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\classes\service\
     文件        1335  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\classes\service\CustomerService.class
     目录           0  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\classes\servlet\
     文件        4661  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\classes\servlet\CustomerServlet.class
     目录           0  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\lib\
     文件      497865  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\lib\c3p0-0.9.5.2.jar
     文件      246174  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\lib\commons-beanutils-1.9.3.jar
     文件      588337  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\lib\commons-collections-3.2.2.jar
     文件       77857  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\lib\commons-dbutils-1.6.jar
     文件       61829  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\lib\commons-logging-1.2.jar
     文件       25277  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\lib\itcast-tools-1.4.jar
     文件      414240  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\lib\jstl-1.2.jar
     文件      606472  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\lib\mchange-commons-java-0.2.11.jar
     文件      540852  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\lib\mysql-connector-java-5.0.8-bin.jar
     文件         602  2017-04-06 07:48  CustomerManagement-master\out\artifacts\CustomerManagement_war_exploded\WEB-INF\web.xml
............此处省略57个文件信息

评论

共有 条评论