日期:2014-05-17  浏览次数:20752 次

连接持续增加,不能释放,请帮忙看看是不是递归引起,如何解决?
/*   判断该类别下面是否有子类别   */

public   boolean   HasSon(int   parent)   throws   SQLException,   NamingException
        {
                Connection   conn=null;
                PreparedStatement   pstmt   =   null;
                ResultSet   rs=null;
                int   i=0;
                try
                {
                        String   sql= "select   count(*)   total   from   procat   where   parent=? ";
                        conn   =   pool.getConnection();
                        pstmt   =   conn.prepareStatement(sql);
                        pstmt   .setInt(1,parent);
                        rs=pstmt.executeQuery();
                        if(rs.next()){
                            i   =   rs.getInt( "total ");
                        }                        
                }
                finally{
                        pool.cleanup(conn,pstmt,rs);
                }
                return   i> 0;
      }

/*按照深度得到当前类别下面所有类别,递归调用   */

public   void   getCatalog(ArrayList   list,   int   parent,int   depth)   throws   SQLException,NamingException
        {
                Connection   conn=null;
                PreparedStatement   pstmt   =   null;  
                ResultSet   rs=null;        
                String   sql= "select   *   from   procat   where   parent=?   order   by   pos   desc,catid   desc ";
                try{
                        conn=pool.getConnection();
                        pstmt=conn.prepareStatement(sql);
                        pstmt.setInt(1,parent);
                        rs   =