tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sasidhar prabhakar <sasidhar1...@gmail.com>
Subject Re: DBCP abandoned trace - unable to understand the leak
Date Thu, 04 Nov 2010 07:50:48 GMT
We are using struts and following DAO pattern.

This is the code


public String getCountryName(long ipSum){
        String name = null;
       Connection connection = null;
       PreparedStatement pstmt = null;
       ResultSet rs = null;

       try{
             connection = dataSource.getConnection();
             pstmt = connection.prepareStatement("select country_name from
ip_to_geo where ? between ip_from and ip_to");
             pstmt.setString(1, ""+ipSum);
             rs = pstmt.executeQuery();
             if( rs.next() ){
                name = rs.getString(1);
             }

        }catch(Exception ex){
               ex.printStackTrace();
        }finally{
           try{if( rs!=null)rs.close();}catch(SQLException
ex){ex.printStackTrace();}
           try {if( pstmt != null)pstmt.close();} catch (SQLException ex)
{ex.printStackTrace();}
           try {if( connection != null)connection.close();} catch
(SQLException ex) {ex.printStackTrace();}
             connection = null;
             pstmt = null;
              rs = null;
         }

return name;

}

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message