日期:2014-05-18  浏览次数:20712 次

遇到这种情况如何操作!???
static   Connection   con   =   null;
static   Statement   stmt   =   null;
ResultSet   rs   =   null;

在一个页面中要调用好几次同一个数据库。。。我每次调用完毕后要怎么关闭才能不浪费系统资源。。。是仅仅关闭rs   和stmt     还是每调用一次就全部关一次了!!!!!????

------解决方案--------------------
static Connection con = null;//指定为类变量,在你最后一次调用之后调用单独出来的关闭方法
static Statement stmt = null;ResultSet rs = null;//每次操作(方法级)完成之后必须关闭


------解决方案--------------------
使用完后应该:
rs.close();
stmt.close();
conn.close();


下次使用的时候要重新打开Connection

------解决方案--------------------
用连接池把

或者把那三个close写在finally里面