package orz.treeSquirrels.dao;
import orz.treeSquirrels.entity.ProductInfo;
/**
* 商品信息表的接口
* @author Administrator
*
*/
public interface ProductInfoDao {
//添加
public int addProductInfo(ProductInfo pro);
}
对应的实现类(ProductInfoDaoImpl.java):
package orz.treeSquirrels.dao.impl;
/**
* 商品信息表的实现类
*/
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import orz.treeSquirrels.dao.BaseDao;
import orz.treeSquirrels.dao.ProductInfoDao;
import orz.treeSquirrels.entity.ProductInfo;
public class ProductInfoDaoImpl extends BaseDao implements ProductInfoDao {
/**
* (非 Javadoc)
* <p>Title: addProductInfo</p>
* <p>Description:添加商品信息 </p>
* @param pro
* @return
* @see orz.treeSquirrels.dao.ProductInfoDao#addProductInfo(orz.treeSquirrels.entity.ProductInfo)
*/
@Override
public int addProductInfo(ProductInfo pro) {
int rel=0;
String sql="insert ProductInfo(productName,price,details,stock,fileName,fileName_1,fileName_2,fileName_3)" +
" values(?,?,?,?,?,?,?,?)";
List<Object>prams=new ArrayList<Object>();
prams.add(pro.getProductName());
prams.add(pro.getPrice());
prams.add(pro.getDetails());
prams.add(pro.getStock());
prams.add(pro.getFileName());
prams.add(pro.getFileName_1());
prams.add(pro.getFileName_2());
prams.add(pro.getFileName_3());
try {
rel=executeUpdate(sql, prams);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}finally{
closeAll();
}
return rel;
}
}