StringBuffer sb0 = new StringBuffer();
sb0.append("select a.AgentID as AgentID,b.AgentName as AgentName,a.ProductName as ProductName, ");
sb0.append("a.AlertType as AlertType,a.CreatedTime as CreatedTime ");
sb0.append("from assetalertlog a,agentmaster b ");
sb0.append("where a.AgentID = b.AgentID and a.alertType= '0' ");
sb0.append("and a.CreatedTime>? and a.CreatedTime<'20100202235959' ");
sb0.append("and b.AgentName=? ");
sb0.append(" ORDER BY a.CreatedTime desc ");
sb0.append(" LIMIT 0,10");
final List
jdbcTemplate.query(sb0.toString(), new PreparedStatementSetter() {
public void setValues(PreparedStatement preparedStatement)
throws SQLException {
preparedStatement.setObject(1, "20100201000000");
preparedStatement.setObject(2, "pc001");
System.out.println("#######################SQL="+ preparedStatement);
}
}, new RowCallbackHandler() {
public void processRow(ResultSet rs) throws SQLException {
while (rs.next()) {
AssetalertlogDTO assetalertlogDTO = new AssetalertlogDTO();
assetalertlogDTO.setAgentID(rs.getInt("AgentID"));
if ("0".equals(rs.getString("AlertType"))) {
assetalertlogDTO.setAlertType("アプリケーション");
}
assetalertlogDTO.setProductName(rs.getString("ProductName"));
assetalertlogDTO.setCreatedTime(DateOperateUtil.TimestampFormat(rs.getTimestamp("CreatedTime"),"yyyy/MM/dd HH:mm:ss"));
assetalertlogDTO.setPcName(rs.getString("AgentName"));
alertAdobeList.add(assetalertlogDTO);
}
Iterator
while (itr.hasNext()) {
AssetalertlogDTO assetalertlogDTO = (AssetalertlogDTO) itr.next();
System.out.println("#######################ProductName="+ assetalertlogDTO.getAgentID());
}
}
})
0 件のコメント:
コメントを投稿