本文整理汇总了Java中org.springframework.jdbc.core.ParameterizedPreparedStatementSetter类的典型用法代码示例。如果您正苦于以下问题:Java ParameterizedPreparedStatementSetter类的具体用法?Java ParameterizedPreparedStatementSetter怎么用?Java ParameterizedPreparedStatementSetter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParameterizedPreparedStatementSetter类属于org.springframework.jdbc.core包,在下文中一共展示了ParameterizedPreparedStatementSetter类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: batchUpdate
import org.springframework.jdbc.core.ParameterizedPreparedStatementSetter; //导入依赖的package包/类
@Override
public <T> int[][] batchUpdate(String sql, Collection<T> batchArgs, int batchSize, ParameterizedPreparedStatementSetter<T> pss) throws DataAccessException {
LogOperate logOperate = parseOperate(sql);
Assert.notNull(logOperate,"不匹配的操作类型,日志记录失败!");
switch (logOperate){
case DELETE:
batchDeleteRecordLog(logOperate,sql,batchArgs,pss);
break;
case UPDATE:
batchUpdateRecordLog(logOperate,sql,batchArgs,pss);
break;
case INSERT:
batchInsertRecordLog(logOperate,sql,batchArgs,pss);
break;
default:
break;
}
return super.batchUpdate(sql, batchArgs, batchSize, pss);
}
开发者ID:zuonima,项目名称:sql-utils,代码行数:20,代码来源:LogJdbcTemplate.java
示例2: updateUserAgain
import org.springframework.jdbc.core.ParameterizedPreparedStatementSetter; //导入依赖的package包/类
/**
* Exemple d'utilisation du ParameterizedPreparedStatementSetter
* Son int�r�t et de pouvoir utiliser des objets typ�s directement
*
* Par contre, il renvoie un int[][] pour refleter les actions sur chaque batchSize
*/
public int[][] updateUserAgain(final int batchSize, final User... usersToUpdate) {
ParameterizedPreparedStatementSetter<User> ppss = new ParameterizedPreparedStatementSetter<User>() {
@Override
public void setValues(final PreparedStatement ps, final User user) throws SQLException {
ps.setString(1, user.getName());
ps.setString(2, user.getMail());
ps.setInt(3, user.getId());
}
};
return jdbcTemplate.batchUpdate("update users set name = ?, email = ? where id = ?",
Arrays.asList(usersToUpdate), batchSize, ppss);
}
开发者ID:Eulbobo,项目名称:java-samples,代码行数:22,代码来源:Batch.java
示例3: setUp
import org.springframework.jdbc.core.ParameterizedPreparedStatementSetter; //导入依赖的package包/类
@Before
public void setUp(){
logger.info("populating database");
ParameterizedPreparedStatementSetter<String> ppss = new ParameterizedPreparedStatementSetter<String>() {
@Override
public void setValues(PreparedStatement preparedStatement, String s) throws SQLException {
preparedStatement.setString(1, s);
}
};
jdbcTemplate.batchUpdate("DELETE FROM test_data");
int batchSize = 10000;
for(int i=0; i< 5; i++) {
jdbcTemplate.batchUpdate("INSERT INTO test_data (entry) VALUES (?)",
Stream.generate(Math::random).map(String::valueOf).limit(1000000).collect(Collectors.toList()),
batchSize, ppss);
}
logger.info("test data populated");
}
开发者ID:APNIC-net,项目名称:spring-jdbctemplate-streams,代码行数:23,代码来源:JdbcPerformanceTest.java
示例4: batchUpdate
import org.springframework.jdbc.core.ParameterizedPreparedStatementSetter; //导入依赖的package包/类
@Override
public <T> int[][] batchUpdate(
String sql, Collection<T> batchArgs, int batchSize, ParameterizedPreparedStatementSetter<T> ppss) {
if (this.logger.isDebugEnabled()) {
this.logger.debug("Executing SQL batch update [" + sql + "] with a batch size of " + batchSize);
}
try {
return execute(sql, new ParameterizedBatchingPreparedStatementCallback<>(ppss, batchSize, batchArgs));
} finally {
if (ppss instanceof ParameterDisposer) {
((ParameterDisposer) ppss).cleanupParameters();
}
}
}
开发者ID:ferstl,项目名称:spring-jdbc-oracle,代码行数:17,代码来源:OracleJdbcTemplate.java
示例5: doInPreparedStatement
import org.springframework.jdbc.core.ParameterizedPreparedStatementSetter; //导入依赖的package包/类
private void doInPreparedStatement(int batchSize, int batchArgSize) throws SQLException {
@SuppressWarnings("unchecked")
ParameterizedPreparedStatementSetter<String> ppss = mock(ParameterizedPreparedStatementSetter.class);
// Create the arguments for the batch update
ArrayList<String> batchArgs = new ArrayList<>(batchArgSize);
for (int i = 0; i < batchArgSize; i++) {
batchArgs.add(Integer.toString(i));
}
ParameterizedBatchingPreparedStatementCallback<String> psc =
new ParameterizedBatchingPreparedStatementCallback<>(ppss, batchSize, batchArgs);
int[][] result = psc.doInPreparedStatement(this.ops);
assertThat(result, matchesBatchedRowCounts(batchSize, batchArgSize));
verifyPreparedStatementCalls(batchArgSize, ppss);
}
开发者ID:ferstl,项目名称:spring-jdbc-oracle,代码行数:18,代码来源:ParameterizedBatchingPreparedStatementCallbackTest.java
示例6: batchInsertUpdate
import org.springframework.jdbc.core.ParameterizedPreparedStatementSetter; //导入依赖的package包/类
@Override
public void batchInsertUpdate(List<StockModelInfo> dtos) {
template.batchUpdate(BATCH_INSERT, dtos, 100, new ParameterizedPreparedStatementSetter<StockModelInfo>() {
@Override
public void setValues(PreparedStatement ps, StockModelInfo dto) throws SQLException {
ps.setInt(1, dto.getMarket());
ps.setString(2, dto.getStockCode());
ps.setBoolean(3, dto.getIsDel());
Date updateDate = new Date(dto.getUpdateDate().getTime());
ps.setDate(4, updateDate);
ps.setString(5, dto.getStockDescription());
}
});
}
开发者ID:pipingyishi,项目名称:test,代码行数:15,代码来源:StockServiceImpl.java
示例7: batchInsertUpdate
import org.springframework.jdbc.core.ParameterizedPreparedStatementSetter; //导入依赖的package包/类
@Override
public void batchInsertUpdate(List<UserUrlMassage> dtos) {
template.batchUpdate(BATCH_INSERT, dtos, 10, new ParameterizedPreparedStatementSetter<UserUrlMassage>() {
@Override
public void setValues(PreparedStatement ps, UserUrlMassage dto) throws SQLException {
ps.setString(1, dto.getBoardId());
ps.setString(2, dto.getUrlId());
Date updateDate = new Date(dto.getDate().getTime());
ps.setDate(3, updateDate);
ps.setBoolean(4, dto.getIsDel());
ps.setInt(5, dto.getSection());
ps.setBoolean(6, dto.getFlag());
}
});
}
开发者ID:pipingyishi,项目名称:test,代码行数:16,代码来源:UserUrlServiceImpl.java
示例8: ParameterizedBatchingPreparedStatementCallback
import org.springframework.jdbc.core.ParameterizedPreparedStatementSetter; //导入依赖的package包/类
/**
* Constructor.
* @param ppss Parameterized Prepared Statement Setter.
* @param sendBatchSize Size of the batch that will be sent to the DB.
* @param batchArgs Batch arguments.
*/
public ParameterizedBatchingPreparedStatementCallback(
ParameterizedPreparedStatementSetter<T> ppss,
int sendBatchSize,
Collection<T> batchArgs) {
this.ppss = ppss;
this.sendBatchSize = sendBatchSize < batchArgs.size() ? sendBatchSize : batchArgs.size();
this.batchArgs = new ArrayList<>(batchArgs);
}
开发者ID:ferstl,项目名称:spring-jdbc-oracle,代码行数:16,代码来源:ParameterizedBatchingPreparedStatementCallback.java
示例9: verifyPreparedStatementCalls
import org.springframework.jdbc.core.ParameterizedPreparedStatementSetter; //导入依赖的package包/类
private void verifyPreparedStatementCalls(int batchArgSize, ParameterizedPreparedStatementSetter<String> ppss)
throws SQLException {
for (int i = 0; i < batchArgSize; i++) {
verify(ppss).setValues(this.ops, Integer.toString(i));
verify(this.ops, times(batchArgSize)).executeUpdate();
}
}
开发者ID:ferstl,项目名称:spring-jdbc-oracle,代码行数:9,代码来源:ParameterizedBatchingPreparedStatementCallbackTest.java
示例10: batchUpdate
import org.springframework.jdbc.core.ParameterizedPreparedStatementSetter; //导入依赖的package包/类
public <T> int[][] batchUpdate(String sql, Collection<T> batchArgs, int batchSize,
ParameterizedPreparedStatementSetter<T> pss) throws DataAccessException {
return delegate.batchUpdate(sql, batchArgs, batchSize, pss);
}
开发者ID:tramchamploo,项目名称:buffer-slayer,代码行数:5,代码来源:BatchJdbcTemplate.java
示例11: batchUpdate
import org.springframework.jdbc.core.ParameterizedPreparedStatementSetter; //导入依赖的package包/类
@Override
public <T> int[][] batchUpdate(String sql, Collection<T> batchArgs, int batchSize,
ParameterizedPreparedStatementSetter<T> pss) throws DataAccessException {
return super.batchUpdate(sql, batchArgs, batchSize, pss);
}
开发者ID:gxianglong,项目名称:kratos-1,代码行数:7,代码来源:KratosJdbcTemplate.java
示例12: batchUpdateRecordLog
import org.springframework.jdbc.core.ParameterizedPreparedStatementSetter; //导入依赖的package包/类
private void batchUpdateRecordLog(LogOperate operate,String sql, Collection batchArgs, ParameterizedPreparedStatementSetter pss){
}
开发者ID:zuonima,项目名称:sql-utils,代码行数:5,代码来源:LogJdbcTemplate.java
示例13: batchInsertRecordLog
import org.springframework.jdbc.core.ParameterizedPreparedStatementSetter; //导入依赖的package包/类
private void batchInsertRecordLog(LogOperate operate,String sql, Collection batchArgs, ParameterizedPreparedStatementSetter pss){
}
开发者ID:zuonima,项目名称:sql-utils,代码行数:4,代码来源:LogJdbcTemplate.java
示例14: batchDeleteRecordLog
import org.springframework.jdbc.core.ParameterizedPreparedStatementSetter; //导入依赖的package包/类
private void batchDeleteRecordLog(LogOperate operate,String sql, Collection batchArgs, ParameterizedPreparedStatementSetter pss){
}
开发者ID:zuonima,项目名称:sql-utils,代码行数:4,代码来源:LogJdbcTemplate.java
注:本文中的org.springframework.jdbc.core.ParameterizedPreparedStatementSetter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论