📄 goodstypemodel.java
字号:
package com.shop.model;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import com.shop.common.Dbconn;
import com.shop.view.GoodsTypeVo;
public class GoodsTypeModel {
Dbconn db;
public void insertGoodstype(GoodsTypeVo vo) {
db = new Dbconn();
Statement sta = null;
String sql = "insert into shop_goodstype(goodstype_name) values('"
+ vo.getType() + "')";
try {
sta = db.getConn().createStatement();
sta.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public Collection selGoodsTypeAll() {
Collection c = new ArrayList();
db = new Dbconn();
Statement sta = null;
ResultSet rs = null;
String sql = "select * from shop_goodstype";
try {
sta = db.getConn().createStatement();
rs = sta.executeQuery(sql);
while (rs.next()) {
GoodsTypeVo vo = new GoodsTypeVo();
vo.setId(rs.getInt(1));
vo.setType(rs.getString(2));
c.add(vo);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return c;
}
public void deleteGoodsType(int id) {
db = new Dbconn();
Statement sta = null;
String sql = "delete from shop_goodstype where goodstype_id=" + id;
try {
sta = db.getConn().createStatement();
sta.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -