📄 producttypecontrollerimpl.java
字号:
/*
* Created on 2005-12-4
* Author 曹汕
* Version 1.0
* Copyright by CS.SSPKU Inc. All rights reserved.
*/
package com.struts.controller.impl;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import com.struts.business.Product;
import com.struts.business.ProductType;
import com.struts.controller.ProductTypeController;
/**
* @author cs
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class ProductTypeControllerImpl extends ControllerImpl implements ProductTypeController{
private static ProductTypeControllerImpl _instance;
/**
* 单例模式,只创建唯一一个实例
* @return 返还ProductTypeControllerImpl 类的惟一实例
*/
public static synchronized ProductTypeControllerImpl getInstance() {
if (_instance == null)
_instance = new ProductTypeControllerImpl();
return _instance;
}
public ProductTypeControllerImpl(){
super();
}
/**
* 获取产品类别列表
* @return Vector类型对象
*/
public Vector getProductTypeList(){
Vector productTypeList=new Vector();
String sql="select * from producttype order by id";
ResultSet rs=selectRecord(sql);
try {
while(rs.next()){
ProductType pt=new ProductType();
pt.setId(rs.getInt("id"));
pt.setName(rs.getString("name"));
productTypeList.add(pt);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return productTypeList;
}
/**
* 添加产品类型
* @return true or false
*/
public boolean addProductTypeList(ProductType productType){
Vector productTypeList=new Vector();
String sql="insert into producttype(id,name) values()";
if(insertRecord(sql)){
return true;
}
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -