use of org.springframework.jdbc.core.BatchPreparedStatementSetter in project SSM by Intel-bigdata.
the class FileDiffDao method batchUpdate.
public int[] batchUpdate(final List<Long> dids, final FileDiffState state) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
final String sql = "UPDATE " + TABLE_NAME + " SET state = ? " + "WHERE did = ?";
return jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int i) throws SQLException {
ps.setShort(1, (short) state.getValue());
ps.setLong(2, dids.get(i));
}
@Override
public int getBatchSize() {
return dids.size();
}
});
}
use of org.springframework.jdbc.core.BatchPreparedStatementSetter in project SSM by Intel-bigdata.
the class CmdletDao method update.
public int[] update(final List<CmdletInfo> cmdletInfos) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String sql = "UPDATE " + TABLE_NAME + " SET state = ?, state_changed_time = ? WHERE cid = ?";
return jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
public void setValues(PreparedStatement ps, int i) throws SQLException {
ps.setInt(1, cmdletInfos.get(i).getState().getValue());
ps.setLong(2, cmdletInfos.get(i).getStateChangedTime());
ps.setLong(3, cmdletInfos.get(i).getCid());
}
public int getBatchSize() {
return cmdletInfos.size();
}
});
}
use of org.springframework.jdbc.core.BatchPreparedStatementSetter in project SSM by Intel-bigdata.
the class CmdletDao method replace.
public int[] replace(final CmdletInfo[] cmdletInfos) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String sql = "REPLACE INTO " + TABLE_NAME + "(cid, " + "rid, " + "aids, " + "state, " + "parameters, " + "generate_time, " + "state_changed_time)" + " VALUES(?, ?, ?, ?, ?, ?, ?)";
return jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
public void setValues(PreparedStatement ps, int i) throws SQLException {
ps.setLong(1, cmdletInfos[i].getCid());
ps.setLong(2, cmdletInfos[i].getRid());
ps.setString(3, StringUtils.join(cmdletInfos[i].getAidsString(), ","));
ps.setLong(4, cmdletInfos[i].getState().getValue());
ps.setString(5, cmdletInfos[i].getParameters());
ps.setLong(6, cmdletInfos[i].getGenerateTime());
ps.setLong(7, cmdletInfos[i].getStateChangedTime());
}
public int getBatchSize() {
return cmdletInfos.length;
}
});
}
use of org.springframework.jdbc.core.BatchPreparedStatementSetter in project SSM by Intel-bigdata.
the class ActionDao method replace.
public int[] replace(final ActionInfo[] actionInfos) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String sql = "REPLACE INTO " + TABLE_NAME + "(aid, " + "cid, " + "action_name, " + "args, " + "result, " + "log, " + "successful, " + "create_time, " + "finished, " + "finish_time, " + "exec_host, " + "progress)" + " VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
return jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
public void setValues(PreparedStatement ps, int i) throws SQLException {
ps.setLong(1, actionInfos[i].getActionId());
ps.setLong(2, actionInfos[i].getCmdletId());
ps.setString(3, actionInfos[i].getActionName());
ps.setString(4, actionInfos[i].getArgsJsonString());
ps.setString(5, actionInfos[i].getResult());
ps.setString(6, actionInfos[i].getLog());
ps.setBoolean(7, actionInfos[i].isSuccessful());
ps.setLong(8, actionInfos[i].getCreateTime());
ps.setBoolean(9, actionInfos[i].isFinished());
ps.setLong(10, actionInfos[i].getFinishTime());
ps.setString(11, actionInfos[i].getExecHost());
ps.setFloat(12, actionInfos[i].getProgress());
}
public int getBatchSize() {
return actionInfos.length;
}
});
}
use of org.springframework.jdbc.core.BatchPreparedStatementSetter in project SSM by Intel-bigdata.
the class XattrDao method insertXattrList.
public synchronized boolean insertXattrList(final Long fid, final List<XAttribute> attributes) throws SQLException {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String sql = "INSERT INTO xattr (fid, namespace, name, value) VALUES (?, ?, ?, ?)";
int[] i = jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
public void setValues(PreparedStatement ps, int i) throws SQLException {
ps.setLong(1, fid);
ps.setString(2, attributes.get(i).getNameSpace());
ps.setString(3, attributes.get(i).getName());
ps.setBytes(4, attributes.get(i).getValue());
}
public int getBatchSize() {
return attributes.size();
}
});
return i.length == attributes.size();
}
Aggregations