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
10
11
12
13
14 public class CommonProceduresMapper {
15
16 public CommonProceduresMapper() {
17 }
18
19 private String callCloneStatement() {
20 return "{CALL p_clone_enzyme(?, ?, ?, ?)}";
21 }
22
23
24
25
26
27
28
29
30 public Long createClone(Long enzymeId, Connection con) throws SQLException {
31 int newEnzymeId = 0;
32 CallableStatement cStmt = null;
33
34 try {
35 cStmt = con.prepareCall(callCloneStatement());
36 cStmt.setString(1, "" + enzymeId);
37 cStmt.registerOutParameter(2, Types.VARCHAR);
38 cStmt.setString(3, "OK");
39 cStmt.setString(4, "Y");
40 cStmt.execute();
41
42 newEnzymeId = Integer.parseInt(cStmt.getString(2));
43 } finally {
44 if (cStmt != null) cStmt.close();
45 }
46
47 return new Long(newEnzymeId);
48 }
49
50 }