📄 rsseo.java
字号:
package book.rssreader;
import java.sql.ResultSet;
import java.sql.SQLException;
public class RssEO {
public RssEO() {//无参的构造方法
this.rssID = -1;
}
public RssEO(int id) {//有参的构造方法,参数为content_id
this.rssID = id;
if (!FromDb())//如果有找到该id的content
this.rssID = -1;
}
protected int rssID;
protected String rssURL;
protected String rssName;
protected String activeStatus;
public boolean FromDb() {// 从数据库中读出,并更新bean
int row = -1;
// 读记录的sql语句
String sql = "select * from rss where rss_id=" + this.rssID
+ " and active_status='Y'";
ResultSet rs = DbManager.getResultSet(sql);// 执行sql语句并返回ResultSet
try {
rs.last();// 移动到最后一行
row = rs.getRow();// 得到总记录数
if (row == 1) {// 如果只查询到一条记录,则代表该记录存在并更新该类的属性
this.rssName = rs.getString("RSS_LABEL");
this.rssURL = rs.getString("RSS_URL");
this.activeStatus = rs.getString("ACTIVE_STATUS");
return true;
} else
return false;
} catch (SQLException e) {
e.printStackTrace();
return false;
} finally {
try {// 最后关闭ResutltSet,Statement.并释放连接
if (rs != null)
rs.close();
if (rs.getStatement() != null)
rs.getStatement().close();
DbManager.releaseConnection();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public String getActiveStatus() {
return activeStatus;
}
public void setActiveStatus(String activeStatus) {
this.activeStatus = activeStatus;
}
public int getRssID() {
return rssID;
}
public void setRssID(int rssID) {
this.rssID = rssID;
}
public String getRssName() {
return rssName;
}
public void setRssName(String rssName) {
this.rssName = rssName;
}
public String getRssURL() {
return rssURL;
}
public void setRssURL(String rssURL) {
this.rssURL = rssURL;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -