| 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 | 1 | public CommonProceduresMapper() { |
| 17 | 1 | } |
| 18 | |
|
| 19 | |
private String callCloneStatement() { |
| 20 | 1 | 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 | 1 | int newEnzymeId = 0; |
| 32 | 1 | CallableStatement cStmt = null; |
| 33 | |
|
| 34 | |
try { |
| 35 | 1 | cStmt = con.prepareCall(callCloneStatement()); |
| 36 | 1 | cStmt.setString(1, "" + enzymeId); |
| 37 | 1 | cStmt.registerOutParameter(2, Types.VARCHAR); |
| 38 | 1 | cStmt.setString(3, "OK"); |
| 39 | 1 | cStmt.setString(4, "Y"); |
| 40 | 1 | cStmt.execute(); |
| 41 | |
|
| 42 | 1 | newEnzymeId = Integer.parseInt(cStmt.getString(2)); |
| 43 | |
} finally { |
| 44 | 1 | if (cStmt != null) cStmt.close(); |
| 45 | |
} |
| 46 | |
|
| 47 | 1 | return new Long(newEnzymeId); |
| 48 | |
} |
| 49 | |
|
| 50 | |
} |