资源简介
简单的电商网站系统设计,实现功能、登陆、注册、购物车增删改、动态主页等等

代码片段和文件信息
package com.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import com.db.DBUtil;
import com.entity.Items;
public class ItemsDAO {
public ArrayList getAllItems() {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
ArrayList list = new ArrayList(); // 动态数组,存储所有商品
try {
conn = DBUtil.getConnection();
String sql = “select * from items;“;
stmt = conn.prepareStatement(sql);
rs = stmt.executeQuery();
while (rs.next()) {
Items item = new Items();
item.setId(rs.getInt(“id“));
item.setName(rs.getString(“name“));
item.setOrigin(rs.getString(“origin“));
item.setNumber(rs.getInt(“number“));
item.setPrice(rs.getFloat(“price“));
item.setPicture(rs.getString(“picture“));
item.setDescription(rs.getString(“description“));
list.add(item);// 把每一个商品添加至动态数组
}
return list; // 返回数组
} catch (Exception ex) {
ex.printStackTrace();
return null;
} finally {
// 释放资源
closeSrc(rsstmtconn);
}
}
// 通过商品id查找商品
public Items getItemsById(int id) {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = DBUtil.getConnection();
String sql = “select * from items where id=?;“; // SQL语句查找
stmt = conn.prepareStatement(sql);
stmt.setInt(1 id);
rs = stmt.executeQuery();
if (rs.next()) {
Items item = new Items();
item.setId(rs.getInt(“id“));
item.setName(rs.getString(“name“));
item.setOrigin(rs.getString(“origin“));
item.setNumber(rs.getInt(“number“));
item.setPrice(rs.getFloat(“price“));
item.setPicture(rs.getString(“picture“));
item.setDescription(rs.getString(“description“));
return item;
} else {
return null;
}
} catch (Exception ex) {
ex.printStackTrace();
return null;
} finally {
// 释放资源
closeSrc(rsstmtconn);
}
}
// 释放资源
private void closeSrc(ResultSet rsPreparedStatement stmtConnection conn)
{
if (rs != null) {
try {
rs.close();
rs = null;
} catch (Exception ex) {
ex.printStackTrace();
}
}
//
if (stmt != null) {
try {
stmt.close();
stmt = null;
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6148 2018-01-05 15:37 MallDemo\.DS_Store
文件 1165 2018-01-07 19:16 MallDemo\.classpath
文件 64 2018-01-05 15:48 MallDemo\.myumldata
文件 1333 2018-01-05 17:16 MallDemo\.project
文件 522 2015-12-29 10:33 MallDemo\.settings\.jsdtscope
文件 175 2018-01-05 15:43 MallDemo\.settings\com.genuitec.eclipse.core.prefs
文件 86 2018-01-05 15:48 MallDemo\.settings\com.genuitec.jboss.ide.eclipse.xdoclet.run.prefs
文件 45 2018-01-05 15:48 MallDemo\.settings\com.spket.js.prefs
文件 364 2015-12-29 10:33 MallDemo\.settings\org.eclipse.jdt.core.prefs
文件 475 2015-12-29 10:33 MallDemo\.settings\org.eclipse.wst.common.component
文件 414 2015-12-29 10:33 MallDemo\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2015-12-29 10:33 MallDemo\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2015-12-29 10:33 MallDemo\.settings\org.eclipse.wst.jsdt.ui.superType.name
文件 88 2015-12-29 10:33 MallDemo\.settings\org.skyway.core.prefs
文件 66 2015-12-29 10:33 MallDemo\.tern-project
文件 39 2015-12-29 10:34 MallDemo\WebRoot\me
文件 3150 2018-01-17 17:00 MallDemo\WebRoot\WEB-INF\classes\com\dao\ItemsDAO.class
文件 1206 2018-01-17 17:00 MallDemo\WebRoot\WEB-INF\classes\com\db\DBUtil.class
文件 2472 2018-01-17 17:00 MallDemo\WebRoot\WEB-INF\classes\com\entity\Cart.class
文件 2071 2018-01-17 17:00 MallDemo\WebRoot\WEB-INF\classes\com\entity\Items.class
文件 714 2018-01-17 17:00 MallDemo\WebRoot\WEB-INF\classes\com\po\Users.class
文件 3158 2018-01-17 17:00 MallDemo\WebRoot\WEB-INF\classes\com\servlet\CartServlet.class
文件 2214 2018-01-17 17:00 MallDemo\WebRoot\WEB-INF\classes\com\servlet\LoginServlet.class
文件 893229 2017-11-19 16:29 MallDemo\WebRoot\WEB-INF\lib\sqljdbc41.jar
文件 6148 2018-01-08 15:33 MallDemo\WebRoot\assets\.DS_Store
文件 4096 2018-01-08 15:33 MallDemo\WebRoot\assets\._.DS_Store
文件 2817 2018-01-08 15:33 MallDemo\WebRoot\assets\input.png
文件 2831 2018-01-08 15:33 MallDemo\WebRoot\assets\loginbg.png
文件 15584 2018-01-08 15:33 MallDemo\WebRoot\assets\logo.png
文件 2825 2018-01-08 15:33 MallDemo\WebRoot\assets\rep1.png
文件 5345 2018-01-17 17:29 MallDemo\WebRoot\cart.jsp
............此处省略82个文件信息
- 上一篇:基于android的天气预报软件
- 下一篇:JavaWeb购物源码
相关资源
- JSP课程设计-留言本 jsp mysql tomcat实现
- jsp mysql tomcat学生信息管理系统
- websockets实现tomcat日志在线输出
- Spring4.2.9+mybatis3.4.4集成整合Jackson版支
- apache-tomcat-7.0.86.tar.gz
- jsp00357房屋中介管理系统ssh+myeclipse+
- 完整的宿舍管理系统
- android 如何使用tomcat搭建服务器
- Java Web开发实战经典
- myeclipse开发servlet+jsp+oracle+c3p0的java
- tomcat 采用msm连接memcached缓存session所需
- jira6.3汉化包
- Java课程设计超市管理系统Myeclipse+My
- myEclipse实现购物车
- JAVA EE网上考试系统
- Eclipse+Tomcat开发web应用
- MyEclipse-MySQL jsp新闻发布系统
- MyEclipse汉化破解
- jsp网上在线购物系统采用MVC模式 环境
- myeclipse 网上购物系统
- tomcat+nginx反向代理集群配置.zip
- xp安装 JDK+TOMCAT+MYSQL+jsp论坛
- 基于JAVA_MyEclipse图书管理系统
- tomcat 8.5.31
- apache-tomcat-7.0.63-windows-x64.zip
- redis-tomcat8以上集群所需要的jar :tomc
- JSP+Servlet+Tomcat个人博客系统
- jsf2.0 完整(含所有jar包)
- jsp大作业-在线学习平台MyEclipse+Mysql
- JSP+Mysql教师教学质量测评系统论文
评论
共有 条评论