CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
花落谁家,你作主! 盛大widget设计大赛英雄榜
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Java >  J2SE / 基础类

朋友 帮忙!

楼主0legend(很久以前)2002-01-08 14:15:04 在 Java / J2SE / 基础类 提问

Connection   connection   =   DriverManager.getConnection(url,"","");  
  Statement   statement   =   connection.createStatement();  
  ResultSet   rs   =   statement.executeQuery(sql);  
  connection.close();  
   
  statement   应该是依靠这个   connection   ,若   connection.close();  
  是否相应的   statement   被释放,而不必执行statement.close()。  
  statement   automatically   closed   发生在什么时候.请指教!多谢 问题点数:80、回复次数:4Top

1 楼java_alias(六翼黑猫)回复于 2002-01-08 14:17:25 得分 5

关注~~~~~~~~~~Top

2 楼zych72(心平气和)回复于 2002-01-08 14:29:12 得分 30

以下我对jdk中的文档理解,请参考  
  1   关闭Connection   将引起对此Connection所拥有的statement进行garbage   collection,    
  2   关闭Statement   将自动关闭Statement所对应的ResultSet    
  3   虽然1是可以自动执行,但为了系统效率,还是应该在使用完Statement时手动关闭他  
  Top

3 楼javamap()回复于 2002-01-08 14:32:08 得分 40

Connection   is   expensive,   so   if   you   want   to   execute   more   than   one   statements   with   one   connection,   you   want   to   keep   the   connection   open   but   keep   on   creating/closing   statement.  
  However,   this   only   apply   to   JDBC   2.0   or   easier,   because   it   is   not   a   good   design.   Busy   or   huge   applications   want   to   share   connections   (using   connection   pool).   So   with   J2ee   V2.0,   it   is   possible   to   create   a   statement   without   a   connection.   What   you   do   is   to   create   all   statements   and   keep   them   in   memory.   When   you   are   ready   to   execute   one,   open   a   connection.Top

4 楼Patrick_DK(我有我的调调,就是这么屌)回复于 2002-01-08 14:36:27 得分 5

插播:  
   
  请各位高手帮忙给看看  
   
  http://www.csdn.net/expert/topic/463/463710.shtm  
   
  http://www.csdn.net/expert/topic/463/463555.shtm   Top

相关问题

  • 朋友
  • 女朋友
  • :)只送朋友
  • 女朋友...
  • 交个朋友
  • 朋友,你好
  • 交个朋友.
  • 找女朋友!!!
  • 交朋友!!
  • 找朋友啊!

关键词

  • .net
  • statements
  • connection
  • 关闭
  • keep
  • want
  • closing
  • create

得分解答快速导航

  • 帖主:0legend
  • java_alias
  • zych72
  • javamap
  • Patrick_DK

相关链接

  • CSDN Java频道
  • Java类图书
  • Java类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo