日期:2014-05-16 浏览次数:20551 次
try { conn=JdbcProvider.getInstance().getConnection(); sm=conn.prepareStatement(sql);//办事指南 rs=sm.executeQuery(); while(isBSZLExsist && rs.next()){ Map<String,String> map=new HashMap<String, String>(); // map.put("id", rs.getString("id")); map.put("title", rs.getString("title")); map.put("docpuburl",rs.getString("docpuburl")); map.put("docreltime", rs.getString("docreltime")); list3.add(map); } System.out.println("办事指南=="+list3.size()); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } //这边有问题 没有释放数据库资源 if(isExsist || isContentExsist){ try { sm=conn.prepareStatement(sql1);//信箱 rs1=sm.executeQuery(); int count = 0; while(isExsist && rs1.next()){ Map<String,String> map=new HashMap<String, String>(); map.put("id", rs1.getString("id")); map.put("title", rs1.getString("title")); map.put("docpuburl",rs1.getString("docpuburl")); map.put("createdate", rs1.getString("createdate")); list4.add(map); count ++; } } catch (Exception e) { e.printStackTrace(); }finally{ if(conn!=null){ try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } }
try { conn=JdbcProvider.getInstance().getConnection(); sm=conn.prepareStatement(sql);//办事指南 rs=sm.executeQuery(); while(isBSZLExsist && rs.next()){ Map<String,String> map=new HashMap<String, String>(); // map.put("id", rs.getString("id")); map.put("title", rs.getString("title")); map.put("docpuburl",rs.getString("docpuburl")); map.put("docreltime", rs.getString("docreltime")); list3.add(map); } System.out.println("办事指南=="+list3.size()); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); }finally{//正确代码 if(conn!=null){//正确代码 try {//正确代码 conn.close();//正确代码 } catch (SQLException e) {//正确代码 e.printStackTrace();//正确代码 }//正确代码 } } if(isExsist || isContentExsist){ try { conn=JdbcProvider.getInstance().getConnection();//正确代码 sm=conn.prepareStatement(sql1);//信箱 rs1=sm.executeQuery(); int count = 0; while(isExsist && rs1.next()){ Map<String,String> map=new HashMap<String, String>(); map.put("id", rs1.getString("id")); map.put("title", rs1.getString("title")); map.put("docpuburl",rs1.getString("docpuburl")); map.put("createdate", rs1.getString("createdate")); list4.add(map); count ++; } } catch (Exception e) { e.printStackTrace(); }finally{ if(conn!=null){ try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } }