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

资源简介

JSP+servlet+JDBC实现的网上商城项目

资源截图

代码片段和文件信息

package com.softeem.dao;

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

import com.softeem.dto.Category;
import com.softeem.utils.DbConnection;

public class CategoryDAO {

public boolean doCreate(Category c){
Connection conn=null;
 PreparedStatement ps=null;
 ResultSet rs=null;
String sql=“insert into t_category(ca_name) values(?)“;
try{
    conn=DbConnection.getConnection();
    ps=conn.prepareStatement(sql);
            ps.setString(1 c.getCaName());
    if(ps.executeUpdate()>0){
     return true;
    }
    
}catch(SQLException e){
e.printStackTrace();
}finally{
DbConnection.close(conn ps rs);
}
return false;
}

public List findAll(){
Connection conn=null;
PreparedStatement ps=null;
ResultSet rs=null;
List list=new ArrayList();
String sql=“select * from t_category“;
try{
conn=DbConnection.getConnection();
ps=conn.prepareStatement(sql);
rs=ps.executeQuery();
while(rs.next()){
Category c=new Category();
c.setCaId(rs.getInt(“ca_id“));
c.setCaName(rs.getString(“ca_name“));
list.add(c);
}
}catch(SQLException e){
e.printStackTrace();
}finally{
DbConnection.close(conn ps rs);
}
return list;
}

public boolean doDelete(int id){
Connection conn=null;
 PreparedStatement ps=null;
 ResultSet rs=null;
String sql=“delete from t_category where ca_id=?“;
try{
    conn=DbConnection.getConnection();
    ps=conn.prepareStatement(sql);
             ps.setInt(1 id);
    if(ps.executeUpdate()>0){
     return true;
    }
    
}catch(SQLException e){
e.printStackTrace();
}finally{
DbConnection.close(conn ps rs);
}
return false;
}

public boolean doUpdate(Category c){
Connection conn=null;
 PreparedStatement ps=null;
 ResultSet rs=null;
String sql=“update t_category set ca_name=? where ca_id=?“;
try{
    conn=DbConnection.getConnection();
    ps=conn.prepareStatement(sql);
    ps.setString(1 c.getCaName());
            ps.setInt(2c.getCaId());
    if(ps.executeUpdate()>0){
     return true;
    }
    
}catch(SQLException e){
e.printStackTrace();
}finally{
DbConnection.close(conn ps rs);
}
return false;
}

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        613  2011-09-01 14:57  shopping\.classpath

     文件        297  2011-09-28 14:55  shopping\.mymetadata

     文件       1414  2011-08-30 09:45  shopping\.project

     文件       1888  2011-09-07 09:39  shopping\数据库脚本.sql

     文件      12673  2011-09-07 10:00  shopping\WebRoot\index.jsp

     文件       8916  2011-09-06 10:12  shopping\WebRoot\WEB-INF\web.xml

     文件      16263  2011-08-30 11:21  shopping\WebRoot\WEB-INF\tag\c.tld

     文件       7298  2011-08-31 15:44  shopping\WebRoot\WEB-INF\tag\fn.tld

     文件      57779  2011-08-29 14:09  shopping\WebRoot\WEB-INF\lib\commons-fileupload.jar

     文件     109043  2011-08-29 14:09  shopping\WebRoot\WEB-INF\lib\commons-io-1.4.jar

     文件     493105  2011-08-30 11:21  shopping\WebRoot\WEB-INF\lib\mysql-connector-java-5.0.3-bin.jar

     文件       1703  2011-09-06 08:12  shopping\WebRoot\WEB-INF\classes\com\softeem\utils\DbConnection.class

     文件       1782  2011-09-06 08:12  shopping\WebRoot\WEB-INF\classes\com\softeem\utils\IpTimeStamp.class

     文件        606  2011-09-06 08:12  shopping\WebRoot\WEB-INF\classes\com\softeem\utils\StringUtil.class

     文件       2811  2011-09-06 08:12  shopping\WebRoot\WEB-INF\classes\com\softeem\servlet\AddNewsServlet.class

     文件       2507  2011-09-06 08:12  shopping\WebRoot\WEB-INF\classes\com\softeem\servlet\BuyServlet.class

     文件       1500  2011-09-06 08:12  shopping\WebRoot\WEB-INF\classes\com\softeem\servlet\CaDeleteServlet.class

     文件       1765  2011-09-06 08:12  shopping\WebRoot\WEB-INF\classes\com\softeem\servlet\CaQueryServlet.class

     文件       3136  2011-09-06 08:12  shopping\WebRoot\WEB-INF\classes\com\softeem\servlet\CartServlet.class

     文件       1463  2011-09-06 08:12  shopping\WebRoot\WEB-INF\classes\com\softeem\servlet\CategoryServlet.class

     文件       1766  2011-09-06 08:12  shopping\WebRoot\WEB-INF\classes\com\softeem\servlet\CaUpdateServlet.class

     文件       3139  2011-09-06 08:12  shopping\WebRoot\WEB-INF\classes\com\softeem\servlet\CodeServlet.class

     文件       3288  2011-09-06 08:12  shopping\WebRoot\WEB-INF\classes\com\softeem\servlet\ForumServlet.class

     文件       1738  2011-09-06 08:12  shopping\WebRoot\WEB-INF\classes\com\softeem\servlet\InsertServlet.class

     文件       2550  2011-09-06 16:54  shopping\WebRoot\WEB-INF\classes\com\softeem\servlet\LoginServlet.class

     文件       2182  2011-09-06 10:23  shopping\WebRoot\WEB-INF\classes\com\softeem\servlet\PageServlet.class

     文件       3573  2011-09-06 13:13  shopping\WebRoot\WEB-INF\classes\com\softeem\servlet\ProQueryServlet.class

     文件       2025  2011-09-06 08:12  shopping\WebRoot\WEB-INF\classes\com\softeem\servlet\RepassServlet.class

     文件       1852  2011-09-06 08:12  shopping\WebRoot\WEB-INF\classes\com\softeem\servlet\RepassServlet1.class

     文件       2287  2011-09-06 08:12  shopping\WebRoot\WEB-INF\classes\com\softeem\servlet\RepassServlet2.class

............此处省略205个文件信息

评论

共有 条评论

相关资源