📄 topdao.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -