本文整理汇总了Java中org.springframework.jdbc.core.CallableStatementCreator类的典型用法代码示例。如果您正苦于以下问题:Java CallableStatementCreator类的具体用法?Java CallableStatementCreator怎么用?Java CallableStatementCreator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CallableStatementCreator类属于org.springframework.jdbc.core包,在下文中一共展示了CallableStatementCreator类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: callInsert
import org.springframework.jdbc.core.CallableStatementCreator; //导入依赖的package包/类
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);
}
示例2: executeBatch
import org.springframework.jdbc.core.CallableStatementCreator; //导入依赖的package包/类
@Override
public int[] executeBatch() throws SQLException {
if (this.batchItems == null) {
throw new IllegalArgumentException("Batch must have at least one item");
}
final Iterator<Map<String, ?>> params = batchItems.iterator();
return factory.getJdbcTemplate().execute(new CallableStatementCreator() {
@Override
public CallableStatement createCallableStatement(Connection connection) throws SQLException {
return batchFactory.newCallableStatementCreator(params.next()).createCallableStatement(connection);
}
}, new CallableStatementCallback<int[]>() {
@Override
public int[] doInCallableStatement(CallableStatement callableStatement) throws SQLException, DataAccessException {
//add first item to batch
callableStatement.addBatch();
while (params.hasNext()) {
batchFactory.addParameter(callableStatement, params.next());
callableStatement.addBatch();
}
return callableStatement.executeBatch();
}
});
}
示例3: callRetrieve
import org.springframework.jdbc.core.CallableStatementCreator; //导入依赖的package包/类
private Map<String, Object> callRetrieve(String tokenKey, List<SqlParameter> paramList, final String procedureSecurestoreRetrieve) {
Map<String, Object> result = 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);
return result;
}
示例4: executeCallInternal
import org.springframework.jdbc.core.CallableStatementCreator; //导入依赖的package包/类
/**
* 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());
}
示例5: testStoredProcedureConfiguredViaJdbcTemplateWithCustomExceptionTranslator
import org.springframework.jdbc.core.CallableStatementCreator; //导入依赖的package包/类
/**
* Confirm no connection was used to get metadata. Does not use superclass replay
* mechanism.
*
* @throws Exception
*/
@Test
public void testStoredProcedureConfiguredViaJdbcTemplateWithCustomExceptionTranslator()
throws Exception {
given(callableStatement.execute()).willReturn(false);
given(callableStatement.getUpdateCount()).willReturn(-1);
given(callableStatement.getObject(2)).willReturn(5);
given(connection.prepareCall("{call " + StoredProcedureConfiguredViaJdbcTemplate.SQL + "(?, ?)}")
).willReturn(callableStatement);
class TestJdbcTemplate extends JdbcTemplate {
int calls;
@Override
public Map<String, Object> call(CallableStatementCreator csc,
List<SqlParameter> declaredParameters) throws DataAccessException {
calls++;
return super.call(csc, declaredParameters);
}
}
TestJdbcTemplate t = new TestJdbcTemplate();
t.setDataSource(dataSource);
// Will fail without the following, because we're not able to get a connection
// from the DataSource here if we need to to create an ExceptionTranslator
t.setExceptionTranslator(new SQLStateSQLExceptionTranslator());
StoredProcedureConfiguredViaJdbcTemplate sp = new StoredProcedureConfiguredViaJdbcTemplate(t);
assertEquals(sp.execute(11), 5);
assertEquals(1, t.calls);
verify(callableStatement).setObject(1, 11, Types.INTEGER);
verify(callableStatement).registerOutParameter(2, Types.INTEGER);
}
示例6: execute
import org.springframework.jdbc.core.CallableStatementCreator; //导入依赖的package包/类
public <T> T execute(CallableStatementCreator csc,
CallableStatementCallback<T> action) throws DataAccessException {
return delegate.execute(csc, action);
}
示例7: call
import org.springframework.jdbc.core.CallableStatementCreator; //导入依赖的package包/类
public Map<String, Object> call(CallableStatementCreator csc,
List<SqlParameter> declaredParameters) throws DataAccessException {
return delegate.call(csc, declaredParameters);
}
示例8: callRemove
import org.springframework.jdbc.core.CallableStatementCreator; //导入依赖的package包/类
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);
}
示例9: executeCallInternal
import org.springframework.jdbc.core.CallableStatementCreator; //导入依赖的package包/类
/**
* 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());
}
示例10: newCallableStatementCreator
import org.springframework.jdbc.core.CallableStatementCreator; //导入依赖的package包/类
public CallableStatementCreator newCallableStatementCreator(Map<String, ?> params) {
return this.callableStatementCreatorFactory.newCallableStatementCreator(params);
}
示例11: execute
import org.springframework.jdbc.core.CallableStatementCreator; //导入依赖的package包/类
@Override
public <T> T execute(CallableStatementCreator csc, CallableStatementCallback<T> action) throws DataAccessException {
return super.execute(csc, action);
}
示例12: call
import org.springframework.jdbc.core.CallableStatementCreator; //导入依赖的package包/类
@Override
public Map<String, Object> call(CallableStatementCreator csc, List<SqlParameter> declaredParameters)
throws DataAccessException {
return super.call(csc, declaredParameters);
}
示例13: newCallableStatementCreator
import org.springframework.jdbc.core.CallableStatementCreator; //导入依赖的package包/类
/**
* Return a CallableStatementCreator to perform an operation
* with this parameters.
* @param inParams parameters. May be {@code null}.
*/
protected CallableStatementCreator newCallableStatementCreator(Map<String, ?> inParams) {
return this.callableStatementFactory.newCallableStatementCreator(inParams);
}