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.SQLOBJ

UF (Use Freed) issues are reported when there is an attempt to use resources after they were released. The UF.SQLOBJ warning indicates an attempt to use a JDBC object (such as a statement, prepared statement or result set) after it was closed.

Example 1

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

UF.SQLOBJ is reported for the snippet on line 39: the method 'populate(List<String> data, int... keys)' is called on line 39 on every iteration of the cycle. This method is closing the prepared statement 'ps' in case of any SQLException thrown (see line 63). This might cause an attempt to use the closed prepared statemnt on the next iteration of the cycle.