?? topdao.java
字號(hào):
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;
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -