View Javadoc

1   package uk.ac.ebi.intenz.mapper;
2   
3   import java.sql.CallableStatement;
4   import java.sql.Connection;
5   import java.sql.SQLException;
6   import java.sql.Types;
7   
8   /**
9    * Provides methods for audit package access.
10   *
11   * @author Michael Darsow
12   * @version $Revision: 1.2 $ $Date: 2008/01/28 12:33:07 $
13   */
14  public class AuditPackageMapper {
15  
16    public static final String STANDARD_REMARK = "Update by web application.";
17  
18    public AuditPackageMapper() {
19    }
20  
21    private String callStatement() {
22      return "{CALL enzyme.auditpackage.setremark(?)}";
23    }
24  
25    /**
26     * Sets a remark in the audit tables.
27     *
28     * @param remark Remark to be stored in the audit tables.
29     * @param con    The connection.
30     * @throws SQLException
31     */
32    public void setRemark(String remark, Connection con) throws SQLException {
33      CallableStatement cStmt = null;
34  
35      try {
36        cStmt = con.prepareCall(callStatement());
37        if (remark == null){
38      	  cStmt.setNull(1, Types.VARCHAR);
39        } else {
40      	  cStmt.setString(1, remark);
41        }
42        cStmt.executeUpdate();
43      } finally {
44        cStmt.close();
45      }
46    }
47  
48  }