本文整理了Java中org.springframework.jdbc.core.JdbcTemplate.call()
方法的一些代码示例,展示了JdbcTemplate.call()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JdbcTemplate.call()
方法的具体详情如下:
包路径:org.springframework.jdbc.core.JdbcTemplate
类名称:JdbcTemplate
方法名:call
暂无
代码示例来源:origin: spring-projects/spring-framework
/**
* Execute the stored procedure. Subclasses should define a strongly typed
* execute method (with a meaningful name) that invokes this method, populating
* the input map and extracting typed values from the output map. Subclass
* execute methods will often take domain objects as arguments and return values.
* Alternatively, they can return void.
* @param inParams map of input parameters, keyed by name as in parameter
* declarations. Output parameters need not (but can) be included in this map.
* It is legal for map entries to be {@code null}, and this will produce the
* correct behavior using a NULL argument to the stored procedure.
* @return map of output params, keyed by name as in parameter declarations.
* Output parameters will appear here, with their values after the
* stored procedure has been called.
*/
public Map<String, Object> execute(Map<String, ?> inParams) throws DataAccessException {
validateParameters(inParams.values().toArray());
return getJdbcTemplate().call(newCallableStatementCreator(inParams), getDeclaredParameters());
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Delegate method to perform the actual call processing.
*/
private Map<String, Object> executeCallInternal(Map<String, ?> args) {
CallableStatementCreator csc = getCallableStatementFactory().newCallableStatementCreator(args);
if (logger.isDebugEnabled()) {
logger.debug("The following parameters are used for call " + getCallString() + " with " + args);
int i = 1;
for (SqlParameter param : getCallParameters()) {
logger.debug(i + ": " + param.getName() + ", SQL type "+ param.getSqlType() + ", type name " +
param.getTypeName() + ", parameter class [" + param.getClass().getName() + "]");
i++;
}
}
return getJdbcTemplate().call(csc, getCallParameters());
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Execute the stored procedure. Subclasses should define a strongly typed
* execute method (with a meaningful name) that invokes this method, passing in
* a ParameterMapper that will populate the input map. This allows mapping database
* specific features since the ParameterMapper has access to the Connection object.
* The execute method is also responsible for extracting typed values from the output map.
* Subclass execute methods will often take domain objects as arguments and return values.
* Alternatively, they can return void.
* @param inParamMapper map of input parameters, keyed by name as in parameter
* declarations. Output parameters need not (but can) be included in this map.
* It is legal for map entries to be {@code null}, and this will produce the correct
* behavior using a NULL argument to the stored procedure.
* @return map of output params, keyed by name as in parameter declarations.
* Output parameters will appear here, with their values after the
* stored procedure has been called.
*/
public Map<String, Object> execute(ParameterMapper inParamMapper) throws DataAccessException {
checkCompiled();
return getJdbcTemplate().call(newCallableStatementCreator(inParamMapper), getDeclaredParameters());
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Execute the stored procedure with the provided parameter values. This is
* a convenience method where the order of the passed in parameter values
* must match the order that the parameters where declared in.
* @param inParams variable number of input parameters. Output parameters should
* not be included in this map. It is legal for values to be {@code null}, and this
* will produce the correct behavior using a NULL argument to the stored procedure.
* @return map of output params, keyed by name as in parameter declarations.
* Output parameters will appear here, with their values after the stored procedure
* has been called.
*/
public Map<String, Object> execute(Object... inParams) {
Map<String, Object> paramsToUse = new HashMap<>();
validateParameters(inParams);
int i = 0;
for (SqlParameter sqlParameter : getDeclaredParameters()) {
if (sqlParameter.isInputValueProvided() && i < inParams.length) {
paramsToUse.put(sqlParameter.getName(), inParams[i++]);
}
}
return getJdbcTemplate().call(newCallableStatementCreator(paramsToUse), getDeclaredParameters());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testCaseInsensitiveResultsMap() throws Exception {
given(this.callableStatement.execute()).willReturn(false);
given(this.callableStatement.getUpdateCount()).willReturn(-1);
given(this.callableStatement.getObject(1)).willReturn("X");
assertTrue("default should have been NOT case insensitive",
!this.template.isResultsMapCaseInsensitive());
this.template.setResultsMapCaseInsensitive(true);
assertTrue("now it should have been set to case insensitive",
this.template.isResultsMapCaseInsensitive());
Map<String, Object> out = this.template.call(
conn -> conn.prepareCall("my query"), Collections.singletonList(new SqlOutParameter("a", 12)));
assertThat(out, instanceOf(LinkedCaseInsensitiveMap.class));
assertNotNull("we should have gotten the result with upper case", out.get("A"));
assertNotNull("we should have gotten the result with lower case", out.get("a"));
verify(this.callableStatement).close();
verify(this.connection).close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testExecuteClosed() throws Exception {
given(this.resultSet.next()).willReturn(true);
given(this.callableStatement.execute()).willReturn(true);
given(this.callableStatement.getUpdateCount()).willReturn(-1);
SqlParameter param = new SqlReturnResultSet("", (RowCallbackHandler) rs -> {
throw new InvalidDataAccessApiUsageException("");
});
this.thrown.expect(InvalidDataAccessApiUsageException.class);
try {
this.template.call(conn -> conn.prepareCall("my query"), Collections.singletonList(param));
}
finally {
verify(this.resultSet).close();
verify(this.callableStatement).close();
verify(this.connection).close();
}
}
代码示例来源:origin: io.bufferslayer/bufferslayer-spring-jdbc
public Map<String, Object> call(CallableStatementCreator csc,
List<SqlParameter> declaredParameters) throws DataAccessException {
return delegate.call(csc, declaredParameters);
}
代码示例来源:origin: cloudfoundry-incubator/multiapps-controller
private void callRemove(String tokenKey, List<SqlParameter> paramList, String procedureSecurestoreDelete) {
jdbcTemplate.call(new CallableStatementCreator() {
@Override
public CallableStatement createCallableStatement(Connection connection) throws SQLException {
CallableStatement callableStatement = connection.prepareCall(procedureSecurestoreDelete);
callableStatement.setString(1, OAUTH_ACCESS_TOKEN_STORE);
callableStatement.setBoolean(2, FOR_XS_APPLICATIONUSER);
callableStatement.setString(3, tokenKey);
return callableStatement;
}
}, paramList);
}
代码示例来源:origin: io.bufferslayer/buffer-spring-jdbc
public Map<String, Object> call(CallableStatementCreator csc,
List<SqlParameter> declaredParameters) throws DataAccessException {
return delegate.call(csc, declaredParameters);
}
代码示例来源:origin: cloudfoundry-incubator/multiapps-controller
private void callInsert(String tokenKey, List<SqlParameter> paramList, byte[] compressedBytes, String procedureSecurestoreInsert) {
jdbcTemplate.call(new CallableStatementCreator() {
@Override
public CallableStatement createCallableStatement(Connection connection) throws SQLException {
CallableStatement callableStatement = connection.prepareCall(procedureSecurestoreInsert);
callableStatement.setString(1, OAUTH_ACCESS_TOKEN_STORE);
callableStatement.setBoolean(2, FOR_XS_APPLICATIONUSER);
callableStatement.setString(3, tokenKey);
callableStatement.setBytes(4, compressedBytes);
return callableStatement;
}
}, paramList);
}
代码示例来源:origin: cloudfoundry-incubator/multiapps-controller
private Map<String, Object> callRetrieve(String tokenKey, List<SqlParameter> paramList, final String procedureSecurestoreRetrieve) {
return jdbcTemplate.call(new CallableStatementCreator() {
@Override
public CallableStatement createCallableStatement(Connection connection) throws SQLException {
CallableStatement callableStatement = connection.prepareCall(procedureSecurestoreRetrieve);
callableStatement.setString(1, OAUTH_ACCESS_TOKEN_STORE);
callableStatement.setBoolean(2, FOR_XS_APPLICATIONUSER);
callableStatement.setString(3, tokenKey);
callableStatement.registerOutParameter(4, Types.VARBINARY);
return callableStatement;
}
}, paramList);
}
代码示例来源:origin: openstreetmap/osmosis
/**
* Performs post-change database updates.
*/
public void complete() {
dbCtx.getJdbcTemplate().call(
new CallableStatementCreator() {
@Override
public CallableStatement createCallableStatement(Connection con) throws SQLException {
return con.prepareCall("{call osmosisUpdate()}");
}
}, new ArrayList<SqlParameter>());
// Clear all action records.
actionDao.truncate();
}
代码示例来源:origin: org.springframework/org.springframework.jdbc
/**
* Execute the stored procedure. Subclasses should define a strongly typed
* execute method (with a meaningful name) that invokes this method, populating
* the input map and extracting typed values from the output map. Subclass
* execute methods will often take domain objects as arguments and return values.
* Alternatively, they can return void.
* @param inParams map of input parameters, keyed by name as in parameter
* declarations. Output parameters need not (but can) be included in this map.
* It is legal for map entries to be {@code null}, and this will produce the
* correct behavior using a NULL argument to the stored procedure.
* @return map of output params, keyed by name as in parameter declarations.
* Output parameters will appear here, with their values after the
* stored procedure has been called.
*/
public Map<String, Object> execute(Map<String, ?> inParams) throws DataAccessException {
validateParameters(inParams.values().toArray());
return getJdbcTemplate().call(newCallableStatementCreator(inParams), getDeclaredParameters());
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Delegate method to perform the actual call processing.
*/
private Map<String, Object> executeCallInternal(Map<String, ?> args) {
CallableStatementCreator csc = getCallableStatementFactory().newCallableStatementCreator(args);
if (logger.isDebugEnabled()) {
logger.debug("The following parameters are used for call " + getCallString() + " with " + args);
int i = 1;
for (SqlParameter param : getCallParameters()) {
logger.debug(i + ": " + param.getName() + ", SQL type "+ param.getSqlType() + ", type name " +
param.getTypeName() + ", parameter class [" + param.getClass().getName() + "]");
i++;
}
}
return getJdbcTemplate().call(csc, getCallParameters());
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Execute the stored procedure. Subclasses should define a strongly typed
* execute method (with a meaningful name) that invokes this method, populating
* the input map and extracting typed values from the output map. Subclass
* execute methods will often take domain objects as arguments and return values.
* Alternatively, they can return void.
* @param inParams map of input parameters, keyed by name as in parameter
* declarations. Output parameters need not (but can) be included in this map.
* It is legal for map entries to be {@code null}, and this will produce the
* correct behavior using a NULL argument to the stored procedure.
* @return map of output params, keyed by name as in parameter declarations.
* Output parameters will appear here, with their values after the
* stored procedure has been called.
*/
public Map<String, Object> execute(Map<String, ?> inParams) throws DataAccessException {
validateParameters(inParams.values().toArray());
return getJdbcTemplate().call(newCallableStatementCreator(inParams), getDeclaredParameters());
}
代码示例来源:origin: org.springframework/org.springframework.jdbc
/**
* Method to perform the actual call processing
*/
private Map<String, Object> executeCallInternal(Map<String, ?> params) {
CallableStatementCreator csc = getCallableStatementFactory().newCallableStatementCreator(params);
if (logger.isDebugEnabled()) {
logger.debug("The following parameters are used for call " + getCallString() + " with: " + params);
int i = 1;
for (SqlParameter p : getCallParameters()) {
logger.debug(i++ + ": " + p.getName() + " SQL Type "+ p.getSqlType() + " Type Name " + p.getTypeName() + " " + p.getClass().getName());
}
}
return getJdbcTemplate().call(csc, getCallParameters());
}
代码示例来源:origin: org.springframework/org.springframework.jdbc
/**
* Execute the stored procedure. Subclasses should define a strongly typed
* execute method (with a meaningful name) that invokes this method, passing in
* a ParameterMapper that will populate the input map. This allows mapping database
* specific features since the ParameterMapper has access to the Connection object.
* The execute method is also responsible for extracting typed values from the output map.
* Subclass execute methods will often take domain objects as arguments and return values.
* Alternatively, they can return void.
* @param inParamMapper map of input parameters, keyed by name as in parameter
* declarations. Output parameters need not (but can) be included in this map.
* It is legal for map entries to be {@code null}, and this will produce the correct
* behavior using a NULL argument to the stored procedure.
* @return map of output params, keyed by name as in parameter declarations.
* Output parameters will appear here, with their values after the
* stored procedure has been called.
*/
public Map<String, Object> execute(ParameterMapper inParamMapper) throws DataAccessException {
checkCompiled();
return getJdbcTemplate().call(newCallableStatementCreator(inParamMapper), getDeclaredParameters());
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Execute the stored procedure with the provided parameter values. This is
* a convenience method where the order of the passed in parameter values
* must match the order that the parameters where declared in.
* @param inParams variable number of input parameters. Output parameters should
* not be included in this map. It is legal for values to be {@code null}, and this
* will produce the correct behavior using a NULL argument to the stored procedure.
* @return map of output params, keyed by name as in parameter declarations.
* Output parameters will appear here, with their values after the stored procedure
* has been called.
*/
public Map<String, Object> execute(Object... inParams) {
Map<String, Object> paramsToUse = new HashMap<>();
validateParameters(inParams);
int i = 0;
for (SqlParameter sqlParameter : getDeclaredParameters()) {
if (sqlParameter.isInputValueProvided() && i < inParams.length) {
paramsToUse.put(sqlParameter.getName(), inParams[i++]);
}
}
return getJdbcTemplate().call(newCallableStatementCreator(paramsToUse), getDeclaredParameters());
}
代码示例来源:origin: org.springframework/org.springframework.jdbc
/**
* Execute the stored procedure with the provided parameter values. This is
* a convenience method where the order of the passed in parameter values
* must match the order that the parameters where declared in.
* @param inParams variable number of input parameters. Output parameters should
* not be included in this map.
* It is legal for values to be {@code null}, and this will produce the
* correct behavior using a NULL argument to the stored procedure.
* @return map of output params, keyed by name as in parameter declarations.
* Output parameters will appear here, with their values after the
* stored procedure has been called.
*/
public Map<String, Object> execute(Object... inParams) {
Map<String, Object> paramsToUse = new HashMap<String, Object>();
validateParameters(inParams);
int i = 0;
for (SqlParameter sqlParameter : getDeclaredParameters()) {
if (sqlParameter.isInputValueProvided()) {
if (i < inParams.length) {
paramsToUse.put(sqlParameter.getName(), inParams[i++]);
}
}
}
return getJdbcTemplate().call(newCallableStatementCreator(paramsToUse), getDeclaredParameters());
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Execute the stored procedure. Subclasses should define a strongly typed
* execute method (with a meaningful name) that invokes this method, passing in
* a ParameterMapper that will populate the input map. This allows mapping database
* specific features since the ParameterMapper has access to the Connection object.
* The execute method is also responsible for extracting typed values from the output map.
* Subclass execute methods will often take domain objects as arguments and return values.
* Alternatively, they can return void.
* @param inParamMapper map of input parameters, keyed by name as in parameter
* declarations. Output parameters need not (but can) be included in this map.
* It is legal for map entries to be {@code null}, and this will produce the correct
* behavior using a NULL argument to the stored procedure.
* @return map of output params, keyed by name as in parameter declarations.
* Output parameters will appear here, with their values after the
* stored procedure has been called.
*/
public Map<String, Object> execute(ParameterMapper inParamMapper) throws DataAccessException {
checkCompiled();
return getJdbcTemplate().call(newCallableStatementCreator(inParamMapper), getDeclaredParameters());
}
内容来源于网络,如有侵权,请联系作者删除!