MCPcopy Create free account
hub / github.com/cmu-db/benchbase / Procedure

Class Procedure

src/main/java/com/oltpbenchmark/api/Procedure.java:35–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33import org.slf4j.LoggerFactory;
34
35public abstract class Procedure {
36 private static final Logger LOG = LoggerFactory.getLogger(Procedure.class);
37
38 private final String procName;
39 private DatabaseType dbType;
40
41 public DatabaseType getDbType() {
42 return dbType;
43 }
44
45 private Map<String, SQLStmt> name_stmt_xref;
46
47 /** Constructor */
48 protected Procedure() {
49 this.procName = this.getClass().getSimpleName();
50 }
51
52 /**
53 * Initialize all of the SQLStmt handles. This must be called separately from the constructor,
54 * otherwise we can't get access to all of our SQLStmts.
55 *
56 * @param <T>
57 * @return
58 */
59 @SuppressWarnings("unchecked")
60 protected final <T extends Procedure> T initialize(DatabaseType dbType) {
61 this.dbType = dbType;
62 this.name_stmt_xref = Procedure.getStatements(this);
63
64 if (LOG.isDebugEnabled()) {
65 LOG.debug(
66 String.format(
67 "Initialized %s with %d SQLStmts: %s",
68 this, this.name_stmt_xref.size(), this.name_stmt_xref.keySet()));
69 }
70 return ((T) this);
71 }
72
73 /** Return the name of this Procedure */
74 protected final String getProcedureName() {
75 return (this.procName);
76 }
77
78 /**
79 * Return a PreparedStatement for the given SQLStmt handle The underlying Procedure API will make
80 * sure that the proper SQL for the target DBMS is used for this SQLStmt. This will automatically
81 * call setObject for all the parameters you pass in
82 *
83 * @param conn
84 * @param stmt
85 * @param params
86 * @return
87 * @throws SQLException
88 */
89 public final PreparedStatement getPreparedStatement(
90 Connection conn, SQLStmt stmt, Object... params) throws SQLException {
91 PreparedStatement pStmt = this.getPreparedStatementReturnKeys(conn, stmt, null);
92 for (int i = 0; i < params.length; i++) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected