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