package com.thtbase.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import com.thtbase.entity.Record;
import com.thtbase.util.JdbcFactory;
public class ProductDaoImpl implements ProductDao{
public boolean insert(Record r)throws Exception {
Connection conn = JdbcFactory.getConnection();
PreparedStatement stm = null;
String sql = "insert into thtbase values(tht_seq.nextval,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
stm = conn.prepareStatement(sql);
stm.setString(1, r.getSn());
stm.setString(2, r.getPn());
stm.setString(3, r.getType());
stm.setString(4, r.getSPEC());
stm.setString(5, r.getProductDate());
stm.setString(6, r.getGuestName());
stm.setString(7, r.getContractNumber());
stm.setString(8, r.getROMO());
stm.setString(9, r.getDate());
stm.setString(10, r.getROMO1());
stm.setString(11, r.getDate1());
stm.setString(12, r.getROMO2());
stm.setString(13, r.getDate2());
stm.setString(14, r.getShipmentsDate());
stm.setString(15, r.getRecord());
stm.setString(16, r.getRepareDate());
stm.execute();
return true;
}
public Collection<Record> query(String sn) throws Exception{
Connection conn = JdbcFactory.getConnection();
PreparedStatement stm = null;
ResultSet ret = null;
String sql = "select id,sn,pn,type,SPEC,pDate,gName,cNumber,ROMO,date1,ROMO1,date2,ROMO2,date3,sdate,record,rdate from thtbase where sn=?";
stm = conn.prepareStatement(sql);
stm.setString(1, sn);
ret = stm.executeQuery();
Collection col = new ArrayList();
Record record = null;
while(ret.next()){
record = new Record();
record.setId(ret.getInt(1));
record.setSn(ret.getString(2));
record.setPn(ret.getString(3));
record.setType(ret.getString(4));
record.setSPEC(ret.getString(5));
record.setProductDate(ret.getString(6));
record.setGuestName(ret.getString(7));
record.setContractNumber(ret.getString(8));
record.setROMO(ret.getString(9));
record.setDate(ret.getString(10));
record.setROMO1(ret.getString(11));
record.setDate1(ret.getString(12));
record.setROMO2(ret.getString(13));
record.setDate2(ret.getString(14));
record.setShipmentsDate(ret.getString(15));
record.setRecord(ret.getString(16));
record.setRepareDate(ret.getString(17));
col.add(record);
}
return col;
}
public Record queryById(Integer id) throws Exception{
Connection conn = JdbcFactory.getConnection();
PreparedStatement stm = null;
ResultSet ret = null;
String sql = "select id,sn,pn,type,SPEC,pDate,gName,cNumber,ROMO,date1,ROMO1,date2,ROMO2,date3,sdate,record,rdate from thtbase where id=? order by id desc";
stm = conn.prepareStatement(sql);
stm.setInt(1, id);
ret = stm.executeQuery();
Record record = null;
while(ret.next()){
record = new Record();
record.setId(ret.getInt(1));
record.setSn(ret.getString(2));
record.setPn(ret.getString(3));
record.setType(ret.getString(4));
record.setSPEC(ret.getString(5));
record.setProductDate(ret.getString(6));
record.setGuestName(ret.getString(7));
record.setContractNumber(ret.getString(8));
record.setROMO(ret.getString(9));
record.setDate(ret.getString(10));
record.setROMO1(ret.getString(11));
record.setDate1(ret.getString(12));
record.setROMO2(ret.getString(13));
record.setDate2(ret.getString(14));
record.setShipmentsDate(ret.getString(15));
record.setRecord(ret.getString(16));
record.setRepareDate(ret.getString(17));
}
return record;
}
public boolean deleteById(Integer id) {
Connection conn = JdbcFactory.getConnection();
PreparedStatement stm = null;
String sql ="delete from thtbase where id=?";
try {
stm = conn.prepareStatement(sql);
stm.setInt(1, id);
stm.execute();
return true;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
}
}
}
小波思基
- 粉丝: 86
- 资源: 1万+
最新资源
- 校园失物招领网站:设计与实现的全流程解析
- 基于java的公司固定资产管理系统.doc
- 基于java+springboot+vue+mysql的学科竞赛管理系统 源码+数据库+论文(高分毕业设计).zip
- 人工智能领域计算断层成像技术研究最新进展综述
- 微藻检测10-YOLO(v5至v11)、COCO、CreateML、Paligemma、TFRecord、VOC数据集合集.rar
- 快速排序算法在Rust语言的实现及其优化
- 2024年超融合网络架构研究与实践报告.pdf
- 埃森哲:2024年360°价值报告(英文版).pdf
- ISACA中国社区2024女性职业现状调查报告.pdf
- 如何看待“适度宽松”的货币政策.pdf
- 双目立体匹配三维重建点云C++ 本工程基于网上开源代码进行修改,内容如下: 1.修改为 VS2015 Debug win32 版本,支持利用特征点和 OpenCV 立体匹配算法进行进行三维重建及显示
- 华为云AI数字人生态赋能千行百业高效发展.pdf
- 金融业数据安全发展与实践报告.pdf
- 候鸟生命线—共筑候鸟迁徙保护网络.pdf
- 2024年全国统一电力市场建设情况及展望报告.pdf
- 2018-2023年粤港澳、京津冀、长三角三大区域高校本科专业调整趋势.pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈