1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.mitosis.store.derby;
21
22
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25
26 import java.sql.Connection;
27 import java.sql.ResultSet;
28 import java.sql.SQLException;
29 import java.sql.Statement;
30
31
32 class SQLUtil
33 {
34 private static final Logger LOG = LoggerFactory.getLogger( SQLUtil.class );
35
36
37 static void cleanup( Connection con, Statement stmt, ResultSet rs )
38 {
39 if ( rs != null )
40 {
41 try
42 {
43 rs.close();
44 }
45 catch ( SQLException e )
46 {
47 LOG.error( "Failed to close result set.", e );
48 }
49 }
50 if ( stmt != null )
51 {
52 try
53 {
54 stmt.close();
55 }
56 catch ( SQLException e )
57 {
58 LOG.error( "Failed to close statement.", e );
59 }
60 }
61 if ( con != null )
62 {
63 try
64 {
65 con.close();
66 }
67 catch ( SQLException e )
68 {
69 LOG.error( "Failed to close jdbc connection.", e );
70 }
71 }
72 }
73 }