1 package org.dspace.checker; 2 3 import java.sql.Connection ; 4 import java.sql.ResultSet ; 5 import java.sql.SQLException ; 6 import java.sql.Statement ; 7 8 import org.apache.log4j.Logger; 9 import org.dspace.storage.rdbms.DatabaseManager; 10 11 19 public class DAOSupport 20 { 21 22 private static final Logger LOG = Logger.getLogger(DAOSupport.class); 23 24 32 protected void cleanup(Statement stmt, Connection conn) 33 { 34 cleanup(stmt); 35 if (conn != null) 36 { 37 DatabaseManager.freeConnection(conn); 38 } 39 } 40 41 51 protected void cleanup(Statement stmt, Connection conn, ResultSet rs) 52 { 53 if (rs != null) 54 { 55 try 56 { 57 rs.close(); 58 } 59 catch (SQLException e) 60 { 61 LOG.warn("Problem closing result set. " + e.getMessage(), e); 62 } 63 } 64 cleanup(stmt); 65 66 if (conn != null) 67 { 68 DatabaseManager.freeConnection(conn); 69 } 70 } 71 72 protected void cleanup(Statement stmt) 73 { 74 if (stmt != null) 75 { 76 try 77 { 78 stmt.close(); 79 } 80 catch (SQLException e) 81 { 82 LOG.warn("Problem closing prepared statement. " 83 + e.getMessage(), e); 84 } 85 } 86 } 87 88 protected void cleanup(Connection conn) 89 { 90 if (conn != null) 91 { 92 try 93 { 94 conn.close(); 95 } 96 catch (SQLException e) 97 { 98 LOG.warn(e); 99 } 100 } 101 } 102 103 } 104 | Popular Tags |