History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEADEV-13074
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Normal Normal
Assignee: Bas Leijdekkers
Reporter: Serge Baranov
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
IDEA: Development

JDBC resource inspection bug

Created: 06 Oct 06 03:30   Updated: 19 Mar 08 18:39
Component/s: Code Analysis. Inspection
Fix Version/s: Selena 7.0.4, Diana 8243

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown

Build: 5,766
Fixed in build: 8,238
Severity: Medium


 Description  « Hide
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(); }
                        }
                }
        }
}


 All   Comments   Work Log   Change History      Sort Order:
There are no comments yet on this issue.