Java Code Examples for org.springframework.jdbc.core.SingleColumnRowMapper

The following examples show how to use org.springframework.jdbc.core.SingleColumnRowMapper. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: maestro-java   Source File: ReportDao.java    License: Apache License 2.0 6 votes vote down vote up
public int getLastTestId() {
    try {
        Integer ret = runQuery("select MAX(test_id) from report",
                new SingleColumnRowMapper<>(Integer.class));

        if (ret == null) {
            return -1;
        }

        return ret.intValue();
    }
    catch (DataNotFoundException e) {
        logger.warn("The query runner returned data not found. Returning -1 as the next test ID");

        return -1;
    }
}
 
Example 2
Source Project: maestro-java   Source File: ReportDao.java    License: Apache License 2.0 6 votes vote down vote up
public int getLastTestNumber(int testId) {
    try {
        Integer ret = runQuery("select MAX(test_number) from report where test_id = ?",
                new SingleColumnRowMapper<>(Integer.class),
                testId);

        if (ret == null) {
            return -1;
        }

        return ret.intValue();
    }
    catch (DataNotFoundException e) {
        logger.warn("The query runner returned data not found. Returning -1 as the next test number");

        return -1;
    }
}
 
Example 3
Source Project: spring-analysis-note   Source File: NamedParameterJdbcTemplate.java    License: MIT License 5 votes vote down vote up
@Override
@Nullable
public <T> T queryForObject(String sql, SqlParameterSource paramSource, Class<T> requiredType)
		throws DataAccessException {

	return queryForObject(sql, paramSource, new SingleColumnRowMapper<>(requiredType));
}
 
Example 4
Source Project: spring-analysis-note   Source File: NamedParameterJdbcTemplate.java    License: MIT License 5 votes vote down vote up
@Override
@Nullable
public <T> T queryForObject(String sql, Map<String, ?> paramMap, Class<T> requiredType)
		throws DataAccessException {

	return queryForObject(sql, paramMap, new SingleColumnRowMapper<>(requiredType));
}
 
Example 5
Source Project: java-technology-stack   Source File: NamedParameterJdbcTemplate.java    License: MIT License 5 votes vote down vote up
@Override
@Nullable
public <T> T queryForObject(String sql, SqlParameterSource paramSource, Class<T> requiredType)
		throws DataAccessException {

	return queryForObject(sql, paramSource, new SingleColumnRowMapper<>(requiredType));
}
 
Example 6
Source Project: java-technology-stack   Source File: NamedParameterJdbcTemplate.java    License: MIT License 5 votes vote down vote up
@Override
@Nullable
public <T> T queryForObject(String sql, Map<String, ?> paramMap, Class<T> requiredType)
		throws DataAccessException {

	return queryForObject(sql, paramMap, new SingleColumnRowMapper<>(requiredType));
}
 
Example 7
Source Project: DataLink   Source File: DdlUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * !!! Only supports MySQL
 */
@SuppressWarnings("unchecked")
public static List<String> findSchemas(JdbcTemplate jdbcTemplate, final String schemaPattern) {
    try {
        if (StringUtils.isEmpty(schemaPattern)) {
            return jdbcTemplate.query("show databases", new SingleColumnRowMapper(String.class));
        }
        return jdbcTemplate.query("show databases like ?",
                new Object[]{schemaPattern},
                new SingleColumnRowMapper(String.class));
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        return new ArrayList<String>();
    }
}
 
Example 8
Source Project: x7   Source File: DaoImpl.java    License: Apache License 2.0 5 votes vote down vote up
private <K> List<K> queryForPlainValueList(Class<K> clzz, String sql, Criteria.ResultMappedCriteria resultMappedCriteria, Dialect dialect, JdbcTemplate jdbcTemplate) {

        List<Object> valueList = resultMappedCriteria.getValueList();

        if (valueList == null || valueList.isEmpty()) {
            return this.jdbcTemplate.query(sql, new SingleColumnRowMapper<>(clzz));
        }else {
            Object[] arr = dialect.toArr(valueList);
            return this.jdbcTemplate.query(sql, arr,
                    new SingleColumnRowMapper<>(clzz));
        }
    }
 
Example 9
Source Project: spring-analysis-note   Source File: NamedParameterJdbcTemplate.java    License: MIT License 4 votes vote down vote up
@Override
public <T> List<T> queryForList(String sql, SqlParameterSource paramSource, Class<T> elementType)
		throws DataAccessException {

	return query(sql, paramSource, new SingleColumnRowMapper<>(elementType));
}
 
Example 10
private <T> T selectRecipients(@VelocityCheck int companyID, Class<T> type, String sqlStatement, Object... sqlParameters) throws SQLException {
	return selectRecipients(companyID, new SingleColumnRowMapper<>(type), sqlStatement, sqlParameters);
}
 
Example 11
Source Project: java-technology-stack   Source File: NamedParameterJdbcTemplate.java    License: MIT License 4 votes vote down vote up
@Override
public <T> List<T> queryForList(String sql, SqlParameterSource paramSource, Class<T> elementType)
		throws DataAccessException {

	return query(sql, paramSource, new SingleColumnRowMapper<>(elementType));
}
 
Example 12
@Override
public <T> T queryForObject(String sql, SqlParameterSource paramSource, Class<T> requiredType)
		throws DataAccessException {

	return queryForObject(sql, paramSource, new SingleColumnRowMapper<T>(requiredType));
}
 
Example 13
@Override
public <T> T queryForObject(String sql, Map<String, ?> paramMap, Class<T> requiredType)
		throws DataAccessException {

	return queryForObject(sql, paramMap, new SingleColumnRowMapper<T>(requiredType));
}
 
Example 14
@Override
public <T> List<T> queryForList(String sql, SqlParameterSource paramSource, Class<T> elementType)
		throws DataAccessException {

	return query(sql, paramSource, new SingleColumnRowMapper<T>(elementType));
}
 
Example 15
@Override
public <T> T queryForObject(String sql, SqlParameterSource paramSource, Class<T> requiredType)
		throws DataAccessException {

	return queryForObject(sql, paramSource, new SingleColumnRowMapper<T>(requiredType));
}
 
Example 16
@Override
public <T> T queryForObject(String sql, Map<String, ?> paramMap, Class<T> requiredType)
		throws DataAccessException {

	return queryForObject(sql, paramMap, new SingleColumnRowMapper<T>(requiredType));
}
 
Example 17
@Override
public <T> List<T> queryForList(String sql, SqlParameterSource paramSource, Class<T> elementType)
		throws DataAccessException {

	return query(sql, paramSource, new SingleColumnRowMapper<T>(elementType));
}
 
Example 18
@Bean
public JdbcCursorItemReader<Long> addressPrinterReader(final DataSource dataSource) throws Exception {
    final JdbcCursorItemReader<Long> reader = new JdbcCursorItemReader<>();
    reader.setSql(SELECT_ADDRESS_QUERY);
    reader.setRowMapper(new SingleColumnRowMapper<>());
    reader.setDataSource(dataSource);
    reader.setMaxRows(100);
    reader.afterPropertiesSet();
    return reader;
}
 
Example 19
@Bean
public JdbcCursorItemReader<Long> addressBatchTaskDeletionReader(final DataSource dataSource) throws Exception {
    final JdbcCursorItemReader<Long> reader = new JdbcCursorItemReader<>();
    reader.setSql(SELECT_BATCH_TASK_ADDRESS_TO_DELETE_QUERY);
    reader.setRowMapper(new SingleColumnRowMapper<>());
    reader.setDataSource(dataSource);
    reader.setMaxRows(50);
    reader.afterPropertiesSet();
    return reader;
}
 
Example 20
Source Project: effectivejava   Source File: NamedParameterJdbcTemplate.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public <T> T queryForObject(String sql, SqlParameterSource paramSource, Class<T> requiredType)
		throws DataAccessException {

	return queryForObject(sql, paramSource, new SingleColumnRowMapper<T>(requiredType));
}
 
Example 21
Source Project: effectivejava   Source File: NamedParameterJdbcTemplate.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public <T> T queryForObject(String sql, Map<String, ?> paramMap, Class<T> requiredType)
		throws DataAccessException {

	return queryForObject(sql, paramMap, new SingleColumnRowMapper<T>(requiredType));
}
 
Example 22
Source Project: effectivejava   Source File: NamedParameterJdbcTemplate.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public <T> List<T> queryForList(String sql, SqlParameterSource paramSource, Class<T> elementType)
		throws DataAccessException {

	return query(sql, paramSource, new SingleColumnRowMapper<T>(elementType));
}