Priority
Normal
Type
Bug 
State
Fixed 
Assignee
Bas Leijdekkers 
Subsystem
Code Analysis. Inspection 
Affected versions
Fixed in
Fixed in build
Next build 
Build
5766
Fixed in build
8238
Severity
0
  • Submitted by   Serge Baranov
    3 years ago (06 Oct 2006 03:30)
  • Updated by   root
    3 weeks ago (17 Jan 2010 19:35)
  • Jira: IDEA-34765
    (history, comments)

IDEA-34765

JDBC resource inspection bug

1
Support feedback:

I turn on "JDBC resource opened but not safely closed." It works if I use a plain "CallableStatement", but if I cast that to a
subclass, like OracleCallableStatement, that it gets confused and reports that I don't close it, even though I do.



import java.sql.Connection;
import java.sql.SQLException;
import java.sql.CallableStatement;

public class Main
{
        private interface MyStatement extends CallableStatement{}

        public void doit( Connection conn )
        {
                CallableStatement stmt = null;
                MyStatement stmt2 = null;
                try
                {
                        stmt = conn.prepareCall( "xxx" );
                        stmt2 = (MyStatement) conn.prepareCall( "xxx" );
                }
                catch ( SQLException e )
                {
                        e.printStackTrace();
                }
                finally
                {
                        if ( stmt != null )
                        {
                                try { stmt.close();     } catch ( SQLException e ) { e.printStackTrace(); }
                        }
                        if ( stmt2 != null )
                        {
                                try { stmt2.close();    } catch ( SQLException e ) { e.printStackTrace(); }
                        }
                }
        }
}


Issue was resolved
Comments (0)
 
History (1)
 
Links
 
Issue has no comments