Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

UF.SQLCON

UF (Use Freed) issues are reported when there is an attempt to use resources after they were released. The UF.SQLCON warning indicates an attempt to use a JDBC connection after it was closed.

Example 1

26     public List<String> order() {
27         final List<String> strings = new ArrayList<String>();
28         populate(strings, 1, 3, 5, 7, 9);
29         populate(strings, 0, 2, 4, 6, 8);
30         return strings;
31     }
32 
33     public void populate(List<String> data, int... keys) {
34         try {
35             PreparedStatement ps = conn.prepareStatement("SELECT * FROM Table where key=?");
36             try {
37                 for (int key : keys) {
38                     ps.setInt(1, key);
39                     final ResultSet resultSet = ps.executeQuery();
40                     try {
41                         populate(data, resultSet);
42                     } finally {
43                         resultSet.close();
44                     }
45                 }
46             } catch (SQLException e) {
47                 conn.close();
48             }  finally {
49                 ps.close();
50             }
51         } catch (SQLException e) {
52             // do nothing
53         }
54     }
55 
56     public void populate(List<String> data, ResultSet rs) throws SQLException {
57         while (rs.next()) {
58             String s = rs.getString(1);
59             data.add(s);
60         }
61     }

UF.SQLCON is reported for the snippet on line 29 since the method 'populate' called on line 28 is closing the JDBC connection 'conn' in case of any SQLException thrown. That means that the next call to 'populate' on line 29 might attempt to use the closed connection.