use of org.springframework.jdbc.core.RowCallbackHandler in project opennms by OpenNMS.
the class JdbcEventdServiceManager method dataSourceSync.
/* (non-Javadoc)
* @see org.opennms.netmgt.eventd.EventdServiceManager#dataSourceSync()
*/
/**
* <p>dataSourceSync</p>
*/
@Override
public synchronized void dataSourceSync() {
m_serviceMap.clear();
new JdbcTemplate(m_dataSource).query(SQL_DB_SVC_TABLE_READ, new RowCallbackHandler() {
@Override
public void processRow(ResultSet resultSet) throws SQLException {
m_serviceMap.put(resultSet.getString(2), resultSet.getInt(1));
}
});
}
use of org.springframework.jdbc.core.RowCallbackHandler in project opennms by OpenNMS.
the class AlarmdIT method assertEmptyAlarmTable.
private void assertEmptyAlarmTable() {
List<String> alarmDescriptions = new LinkedList<>();
m_jdbcTemplate.query("select alarmId, reductionKey, severity from alarms", new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
alarmDescriptions.add(String.format("Alarm[id=%s, reductionKey=%s, severity=%s]", rs.getString(1), rs.getObject(2), rs.getObject(3)));
}
});
assertEquals("Found one or more alarms: " + alarmDescriptions, 0, alarmDescriptions.size());
}
use of org.springframework.jdbc.core.RowCallbackHandler in project ignite by apache.
the class CacheSpringPersonStore method loadCache.
/** {@inheritDoc} */
@Override
public void loadCache(final IgniteBiInClosure<Long, Person> clo, Object... args) {
if (args == null || args.length == 0 || args[0] == null)
throw new CacheLoaderException("Expected entry count parameter is not provided.");
int entryCnt = (Integer) args[0];
final AtomicInteger cnt = new AtomicInteger();
jdbcTemplate.query("select * from PERSON limit ?", new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
Person person = new Person(rs.getLong(1), rs.getString(2), rs.getString(3));
clo.apply(person.id, person);
cnt.incrementAndGet();
}
}, entryCnt);
System.out.println(">>> Loaded " + cnt + " values into cache.");
}
use of org.springframework.jdbc.core.RowCallbackHandler in project dal by ctripcorp.
the class DaoBySqlBuilder method updateTask.
public int updateTask(GenTaskBySqlBuilder task) {
final List<Integer> counts = new ArrayList<>();
this.jdbcTemplate.query("SELECT 1 FROM task_auto WHERE id != ? AND project_id=? AND db_name=? AND table_name=? AND method_name=? LIMIT 1", new Object[] { task.getId(), task.getProject_id(), task.getDatabaseSetName(), task.getTable_name(), task.getMethod_name() }, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
counts.add(1);
}
});
if (counts.size() > 0)
return -1;
return this.jdbcTemplate.update("UPDATE task_auto SET project_id=?,db_name=?, table_name=?, class_name=?,method_name=?," + "sql_style=?,crud_type=?,fields=?,where_condition=?,sql_content=?,`generated`=?," + "version=version+1,update_user_no=?,update_time=?,comment=?,scalarType=?," + "pagination=?,orderby=?,approved=?,approveMsg=?,hints=? WHERE id=? AND version = ?", task.getProject_id(), task.getDatabaseSetName(), task.getTable_name(), task.getClass_name(), task.getMethod_name(), task.getSql_style(), task.getCrud_type(), task.getFields(), task.getCondition(), task.getSql_content(), task.isGenerated(), task.getUpdate_user_no(), task.getUpdate_time(), task.getComment(), task.getScalarType(), task.isPagination(), task.getOrderby(), task.getApproved(), task.getApproveMsg(), task.getHints(), task.getId(), task.getVersion());
}
use of org.springframework.jdbc.core.RowCallbackHandler in project dal by ctripcorp.
the class DaoBySqlBuilder method updateAndGetTasks.
public List<GenTaskBySqlBuilder> updateAndGetTasks(int projectId) {
final List<GenTaskBySqlBuilder> tasks = new ArrayList<>();
this.jdbcTemplate.query(" SELECT id, project_id, db_name,table_name,class_name,method_name,sql_style, " + " crud_type,fields,where_condition,sql_content,`generated`,version,update_user_no, " + " update_time,comment,scalarType,pagination,orderby,approved,approveMsg,hints " + " FROM task_auto " + " WHERE project_id=? AND `generated`=FALSE", new Object[] { projectId }, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
GenTaskBySqlBuilder task = GenTaskBySqlBuilder.visitRow(rs);
task.setGenerated(true);
if (updateTask(task) > 0) {
tasks.add(task);
}
}
});
return tasks;
}
Aggregations