package s2jsp.bysj.dao;
import java.sql.*;
import java.util.*;
import s2jsp.bysj.entity.*;
public class ProductDao extends BaseDao {
private Connection conn = null;
private PreparedStatement pstmt = null;
private ResultSet rs = null;
public static final int PAGE_NUM = 5;
// taotao
public List findAllProduct() {
List list = new ArrayList();
String sql = "select * from Product";
try {
conn = this.getConn();
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next()) {
Product p = new Product();
p.setProductID(rs.getInt(1));
p.setSerialNumber(rs.getString(2));
p.setName(rs.getString(3));
p.setBrand(rs.getString(4));
p.setModel(rs.getString(5));
p.setPrice(rs.getDouble(6));
p.setPicture(rs.getString(7));
p.setDescription(rs.getString(8));
list.add(p);
}
} catch (SQLException e) {
System.out.println("查询商品信息失败!");
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} finally {
this.closeAll(conn, pstmt, rs);
}
return list;
}
// taotao在页面中显示商品信息
public Product findProductByID(int productID) {
Product p = new Product();
String sql = "select * from product where productID=?";
try {
conn = this.getConn();
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, productID);
rs = pstmt.executeQuery();
while (rs.next()) {
p.setProductID(rs.getInt(1));
p.setSerialNumber(rs.getString(2));
p.setName(rs.getString(3));
p.setBrand(rs.getString(4));
p.setModel(rs.getString(5));
p.setPrice(rs.getDouble(6));
p.setPicture(rs.getString(7));
p.setDescription(rs.getString(8));
}
} catch (SQLException e) {
System.out.println("查询商品详细信息失败!");
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} finally {
this.closeAll(conn, pstmt, rs);
}
return p;
}
// 分页的实现
public List findProductGroup(int page) {
List list = new ArrayList();
int number = 0;
if (page > 1) {
number = PAGE_NUM * (page - 1);
}
String sql = "select top "
+ PAGE_NUM
+ " * from product where productid not in(select top "
+ number
+ " productid from product order by productid desc)order by productid desc";
try {
conn = this.getConn();
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next()) {
Product p = new Product();
p.setProductID(rs.getInt(1));
p.setSerialNumber(rs.getString(2));
p.setName(rs.getString(3));
p.setBrand(rs.getString(4));
p.setModel(rs.getString(5));
p.setPrice(rs.getDouble(6));
p.setPicture(rs.getString(7));
p.setDescription(rs.getString(8));
list.add(p);
}
} catch (SQLException e) {
System.out.println("分页查询失败!");
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} finally {
this.closeAll(conn, pstmt, rs);
}
return list;
}
// longlong添加Product
public int InsertProduct(Product product) {
int result = 0;
String sql = "insert into product (serialNumber,name,brand,model,price,picture,description) values(?,?,?,?,?,?,?)";
try {
conn = this.getConn();
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, product.getSerialNumber());
pstmt.setString(2, product.getName());
pstmt.setString(3, product.getBrand());
pstmt.setString(4, product.getModel());
pstmt.setDouble(5, product.getPrice());
pstmt.setString(6, product.getPicture());
pstmt.setString(7, product.getDescription());
result = pstmt.executeUpdate();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally {
this.closeAll(conn, pstmt, rs);
}
return result;
}
// longlong查询Product
public List selectProduct() {
List list = new ArrayList();
String sql = "select * from product";
try {
conn = this.getConn();
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next()) {
Product p = new Product();
p.setProductID(rs.getInt(1));
p.setSerialNumber(rs.getString(2));
p.setName(rs.getString(3));
p.setBrand(rs.getString(4));
p.setModel(rs.getString(5));
p.setPrice(rs.getDouble(6));
p.setPicture(rs.getString(7));
p.setDescription(rs.getString(8));
list.add(p);
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally {
this.closeAll(conn, pstmt, rs);
}
return list;
}
// longlong删除product
public int deleteProduct(Product product) {
int result = 0;
String sql = "delete from product where productid=?";
try {
conn = this.getConn();
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, product.getProductID());
result = pstmt.executeUpdate();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally {
this.closeAll(conn, pstmt, rs);
}
return result;
}
// longlong通过productid查询procuct
public Product selectProductById(int productid) {
Product product = new Product();
String sql = "select * from product where productid=?";
try {
conn = this.getConn();
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, productid);
rs = pstmt.executeQuery();
while (rs.next()) {
product = new Product();
product.setProductID(productid);
product.setSerialNumber(rs.getString(2));
product.setName(rs.getString(3));
product.setBrand(rs.getString(4));
product.setModel(rs.getString(5));
product.setPrice(rs.getDouble(6));
product.setPicture(rs.getString(7));
product.setDescription(rs.getString(8));
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally {
this.closeAll(conn, pstmt, rs);
}
return product;
}
// longlong修改product
public int updateProduct(Product product) {
int result = 0;
String sql = "update product set name=?,brand=?,model=?,price=?,description=? where productid=?";
try {
conn = this.getConn();
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, product.getName());
pstmt.setString(2, product.getBrand());
pstmt.setString(3, product.getModel());
pstmt.setDouble(4, product.getPrice());
pstmt.setString(5, product.getDescription());
pstmt.setInt(6, product.getProductID());
result = pstmt.executeUpdate();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally {
this.closeAll(conn, pstmt, rs);
}
return result;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
自己写的jsp企业网站代码
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共292个文件
gif:117个
jpg:80个
jsp:50个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
![star](https://csdnimg.cn/release/downloadcmsfe/public/img/star.98a08eaa.png)
温馨提示
就是一个用jsp做的企业网站源代码。大家可以看看,指导知道,呵呵。。
资源推荐
资源详情
资源评论
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
共 292 条
- 1
- 2
- 3
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
- su3qi4er52011-10-26挺好的,就是没有数据库,谢谢啦
- ghk3202012-07-19写的还可以 不过这些代码度是特定环境中才有意义的
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
gongxiaolong_520
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- yolo开发教程&案例&相关项目举例概要知识点总结.docx
- java期末大作业学生成绩管理系统源码+数据库+报告文档(95分以上)
- 1996-2023年各省农林牧渔总产值及农业、林业、牧业、渔业总产值数据(无缺失).xlsx
- vue开发教程&案例&相关项目举例说明概要知识点总结.docx
- ExtJs使用示例代码之窗口组件和异步请求
- 18508319_5640_FlowerShop.zip
- 网络安全相关的密码学、网络攻防、安全分析等项目举例与概要.docx
- java期末大作业课程设计学生成绩管理系统源码+数据库+报告(高分项目)
- maven下载、安装、配置与使用教程概要说明与总结.docx
- kubebuilder v4.0.0
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)