SqlServerStatementCreator implements CallableStatementCreator { public String createCall(String procedureName, int parameterCount) { StringBuffer sb = new StringBuffer("{ CALL ").append(procedureName); if(parameterCount > 0) sb.append("("); for (int i = 0; i < parameterCount; i++) { sb.append("?"); if (i < parameterCount - 1) { sb.append(", "); } } if(parameterCount > 0) sb.append(")"); sb.append("}"); return sb.toString(); }  String createCall(String procedureName, int parameterCount);  }
@Test public void testCreate() { SqlServerStatementCreator creator = new SqlServerStatementCreator(); assertEquals("{ CALL mystoredProcedure(?, ?)}", creator.createCall("mystoredProcedure", 2)); assertEquals("{ CALL mystoredProcedure}", creator.createCall("mystoredProcedure", 0)); }