logo       


My Bug or Bug in Findbugs ???: msg#00000

Subject: My Bug or Bug in Findbugs ???
Hi,

i am currently checking some code of mine wiht findbugs and in the snipplet 
(attached at the end)
i receive an findbugs message on the following line :
ps = con.prepareStatement("select * from table");

The message is :
ODR Exception :

Method may fail to close database resource on exception

The method creates a database resource (such as a database connection or row 
set), does not assign it to any fields, pass it to other methods, or return it, 
and does not appear to 
 close the object on all exception paths out of the method. Failure to close 
database resources on all paths out of a method may result in poor performance, 
and could cause the 
 application to have problems communicating with the database.

I cannot see, why i get this message and why i only get it for the 
PreparedStatement.
Can anyone give me an hint, if this is really a bug in source or if findbugs 
cannot handle the code correctly.

Kind Regards
Mathias


public void showDatabaseContent() {

        Connection con = null;
        ResultSet rs = null;
        PreparedStatement ps = null;                    
        try {
                con = DataSource.getConnection(); // a JBoss Datasource
                ps = con.prepareStatement("select * from table");
                rs = ps.executeQuery();                         
                while (rs.next()) {
                        // evaluation of ResultSet;
                }
                rs.close();
                ps.close();
                con.close();
        } catch (Exception ex) {
                ex.printStackTrace();
        } finally {                     
                if (rs != null) {
                        try {
                                rs.close();
                        } catch (SQLException e) {
                                e.printStackTrace();
                        }
                }
                if (ps != null) {
                        try {
                                ps.close();
                        } catch (SQLException e) {
                                e.printStackTrace();
                        }
                }
                if (con != null) {
                        try {
                                con.close();
                        } catch (SQLException e) {
                                e.printStackTrace();
                        }
                }
        }
}






Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
Search:
Java, servers, webhosts, VoIP...
more...
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
encryption.gpg....    ietf.rfc822/199...    freebsd.devel.i...    lang.haskell.li...    mail.squirrelma...    web.zope.plone....    yellowdog.gener...    text.xml.xalan....    recreation.phot...    kde.devel.educa...    hardware.bus.ca...    printing.ghosts...    voip.peering/20...    assembly/2006-0...    org.user-groups...    culture.interne...    network.i2p/200...    boot-loaders.ya...    xfree86.render/...    qnx.openqnx.dev...    jakarta.velocit...    user-groups.pal...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe