topdao.java
来自「JSP实现的在线网络购物系统JAVA程序源码,」· Java 代码 · 共 56 行
JAVA
56 行
package com.shopping.dao;
import java.sql.*;
import java.util.*;
import com.comm.db.*;
import com.comm.vo.*;
public class TopDao {
public void add(GenericVO gvo) throws SQLException {
String name = gvo.getItemStr("NAME");
String type = gvo.getItemStr("TYPE");
if (type.length() == 0) {
type = "1";
}
String sql = "INSERT INTO top (name, type) VALUES ('" + name + "', " +
type + ")";
DBFactory.getDBI().execute(sql);
}
public void modify(GenericVO gvo) throws SQLException {
String topId = gvo.getItemStr("TOP_ID");
String name = gvo.getItemStr("NAME");
String sql = "UPDATE top SET name = '" + name + "' WHERE top_id=" +
topId;
DBFactory.getDBI().execute(sql);
}
public void delete(int topId) throws SQLException {
String sql = "DELETE FROM top WHERE top_id=" + topId;
DBFactory.getDBI().execute(sql);
}
public Vector get() throws SQLException {
String sql = "SELECT * FROM top ORDER BY top_id";
return DBFactory.getDBI().getResult(sql);
}
public Vector getByType(int type) throws SQLException {
String sql = "SELECT * FROM top WHERE type=" + type +
" ORDER BY top_id";
return DBFactory.getDBI().getResult(sql);
}
public GenericVO getDetail(int topId) throws SQLException {
String sql = "SELECT * FROM top WHERE top_id=" + topId;
Vector r = DBFactory.getDBI().getResult(sql);
if (r.size() > 0) {
return (GenericVO) r.elementAt(0);
} else {
return null;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?