interestdao.java
来自「该源码包括了基于J2EE的数据持久层设计,设计中使用了DAO,Service,等」· Java 代码 · 共 67 行
JAVA
67 行
package org.conference.datapersistence.Dao;
import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.sql.DataSource;
import org.javawing.component.jdbc.core.RowCallbackHandler;
import org.javawing.component.jdbc.core.support.JdbcDaoSupport;
import org.conference.datapersistence.Bo.UserVO;
public class InterestDao extends JdbcDaoSupport implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
public InterestDao(DataSource dataSource) {
this.setDataSource(dataSource);
}
public List doFindInterestsbyId(int id) {
final List interests = new ArrayList();
String Query = "select interest from interest where iid=" + id;
this.getJdbcTemplate().query(Query, new RowCallbackHandler() {
public void processRow(ResultSet rs) throws SQLException {
interests.add(rs.getString("interest"));
}
});
return interests;
}
public String isexist(String interest) {
final UserVO user=new UserVO();
String Query = "select interest from interest where interest='" + interest+"'";
this.getJdbcTemplate().query(Query, new RowCallbackHandler() {
public void processRow(ResultSet rs) throws SQLException {
user.setInterests(rs.getString("interest"));
}
});
return user.getInterests();
}
public int doFindMaxinterestid() {
String interestid = (String) this.getJdbcTemplate().queryForObject(
"select max(iid) from interest", String.class);
return (Integer.parseInt(interestid)) + 1;
}
public int doFindIdbyname(String name) {
return this.getJdbcTemplate().queryForInt(
"select iid from interest where interest='" + name + "'");
}
public int doStore(String interest) {
String storeQuery = "insert into interest(interest)values('" + interest
+ "')";
return this.getJdbcTemplate().update(storeQuery);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?