Spring3.x 之ScrollableSupportJdbcTemplate

public class ScrollableSupportJdbcTemplate extends SimpleJdbcTemplate {

public ScrollableSupportJdbcTemplate(DataSource dataSource) {
super(dataSource);
}

public ScrollableSupportJdbcTemplate(JdbcOperations classicJdbcTemplate) {
super(classicJdbcTemplate);
}

public ScrollableSupportJdbcTemplate( NamedParameterJdbcOperations namedParameterJdbcTemplate)
{
super(namedParameterJdbcTemplate);
}
/* (non-Javadoc)
* @see org.springframework.jdbc.core.simple.SimpleJdbcTemplate#queryForObject(java.lang.String, org.springframework.jdbc.core.simple.ParameterizedRowMapper, java.lang.Object[])
*/
@Override
public <T> T queryForObject(String sql, RowMapper<T> mapper, Object... args) throws DataAccessException {
try {
return super.queryForObject(sql, mapper, convertParams(args));
} catch(EmptyResultDataAccessException e){
}
return null;
}

/* (non-Javadoc)
* @see org.springframework.jdbc.core.simple.SimpleJdbcTemplate#queryForInt(java.lang.String, java.lang.Object[])
*/
@Override
public int queryForInt(String sql, Object... args) throws DataAccessException {
try {
return super.queryForInt(sql, convertParams(args));
} catch(EmptyResultDataAccessException e){
}
return 0;
}
/* (non-Javadoc)
* @see org.springframework.jdbc.core.simple.SimpleJdbcTemplate#queryForLong(java.lang.String, java.lang.Object[])
*/
@Override
public long queryForLong(String sql, Object... args) throws DataAccessException {
try {
return super.queryForLong(sql, convertParams(args));
} catch(EmptyResultDataAccessException e){
}
return 0;
}

public double queryForDouble(String sql, Object... args) throws DataAccessException
{
Double d = queryForObject(sql, Double.class, args);
return (d == null)? 0 : d;
}
。。。。。。。。。。。。。。

你可能感兴趣的:(JdbcTemplate)