JiveJdon Community Forums
在线112人   首页   主题表   培训咨询   标签   精华   查搜   注册    登陆 RSS
首页 » 论坛 » 开源JdonFramework及其应用案例论坛
???en_US.forumThreadPrev.name??? 上一主题
google yahoo 365Key网摘 CSDN网摘 添加到百度搜藏 POCO网摘 新浪ViVi 天极网摘
???en_US.forumThreadNext.name??? 下一主题
Go 共有 3 回复 / 1
 发表新帖子   回复该主题贴
uu_snow

悄悄话
发表文章: 55
注册时间: 2002年11月29日 10:52
在JIVE中,为什么它从来不关闭RESULTSET呢??? 2003年06月02日 13:01 到本帖网址 加入本帖到收藏夹 回复该主题
标签
比如在DbAuthorizationFactory.java中有:
public Authorization createAuthorization(String username, String password)
throws UnauthorizedException
{
if (username == null || password == null) {
throw new UnauthorizedException();
}
//Jive stores all passwords in hashed form. So, hash the plain text
//password for comparison.
password = StringUtils.hash(password);
long userID = 0;
Connection con = null;
PreparedStatement pstmt = null;
try {
con = ConnectionManager.getConnection();
pstmt = con.prepareStatement(AUTHORIZE);
pstmt.setString(1, username);
pstmt.setString(2, password);

ResultSet rs = pstmt.executeQuery();
//If the query had no results, the username and password
//did not match a user record. Therefore, throw an exception.
if (!rs.next()) {
throw new UnauthorizedException();
}
userID = rs.getLong(1);
}
catch( SQLException sqle ) {
System.err.println("Exception in DbAuthorizationFactory:" + sqle);
sqle.printStackTrace();
throw new UnauthorizedException();
}
finally {
try { pstmt.close(); }
catch (Exception e) { e.printStackTrace(); }
try { con.close(); }
catch (Exception e) { e.printStackTrace(); }
}
//Got this far, so the user must be authorized.
return new DbAuthorization(userID);
}

它没有关闭RESULTSET
这样可以吗?
thinkman

悄悄话
发表文章: 5
注册时间: 2003年06月03日 14:58
Re: 在JIVE中,为什么它从来不关闭RESULTSET呢??? 2003年06月03日 15:37 到本帖网址 加入本帖到收藏夹 回复该主题
创建ResultSet的Statement关闭之后,ResultSet会自动关闭
uu_snow

悄悄话
发表文章: 55
注册时间: 2002年11月29日 10:52
Re: 在JIVE中,为什么它从来不关闭RESULTSET呢??? 2003年06月03日 17:03 到本帖网址 加入本帖到收藏夹 回复该主题
那就是说,只要我保证把
PrepareStatement或Statement
关闭了
就不用在程序里写rs.close了?
thinkman

悄悄话
发表文章: 5
注册时间: 2003年06月03日 14:58
Re: 在JIVE中,为什么它从来不关闭RESULTSET呢??? 2003年06月03日 18:06 到本帖网址 加入本帖到收藏夹 回复该主题
yes
标签
共有 3 回复 / 1Go
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表    返回页首返回页首
???en_US.forumThreadNext.name??? 下一主题
热点TAG:
正在读取,请等待...
查询本论坛内 回复超过的热门帖子
标题
 
粗体: [b]文本[/b] 斜体: [i]文本[/i] 下划线 [u]文本[/u] 插入图片 [img]http://wwww.xxxx.com/img.ext[/img] 插入代码 [code]程序代码[/code]  插入url链接 [url]http://url[/url] / [url=http://url]URL加下滑线[/url] 插入附件 插入word文档 Txt等文件
内容
  提交时自动拷贝以上内容到剪贴板 Ctrl-V可取出;提问题前先查询标签列表

RSS 手机阅读 add to google add to yahoo
解惑之道在J道 ,打造中国最具影响力的的企业软件社区 推荐Chrome快速浏览本站
OpenSource JIVEJDON v3.5 Powered by JdonFramework Code © 2002-09 jdon.com

anti spam