本文整理汇总了Java中org.springframework.jdbc.core.simple.SimpleJdbcTemplate.queryForObject方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleJdbcTemplate.queryForObject方法的具体用法?Java SimpleJdbcTemplate.queryForObject怎么用?Java SimpleJdbcTemplate.queryForObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.jdbc.core.simple.SimpleJdbcTemplate
的用法示例。
在下文中一共展示了SimpleJdbcTemplate.queryForObject方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadData
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; //导入方法依赖的package包/类
protected FileInfo loadData(ServerRequest sr) throws IOException, DataAccessException {
if (!(sr instanceof TableServerRequest)) {
throw new IllegalArgumentException("FileInfoProcessor.loadData Requires an TableServerRequest");
}
TableServerRequest request= (TableServerRequest)sr;
SimpleJdbcTemplate jdbc = JdbcFactory.getSimpleTemplate(getDbInstance());
String sql = getSql(request);
Object[] params = getSqlParams(request);
final FileInfoRowMapper fim = makeRowMapper(request);
ParameterizedRowMapper<FileInfo> mapper = new ParameterizedRowMapper<FileInfo>() {
public FileInfo mapRow(ResultSet resultSet, int i) throws SQLException {
return fim.mapRow(resultSet, i);
}
};
LOGGER.info("Executing SQL query: " + sql,
" Parameters: " + "{" + CollectionUtil.toString(params) + "}");
FileInfo val = jdbc.queryForObject(sql, mapper, params);
return val;
}
示例2: getConversation
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; //导入方法依赖的package包/类
public Conversation getConversation(int id) throws DataAccessException {
try {
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue(ID, id, Types.INTEGER);
SimpleJdbcTemplate template = new SimpleJdbcTemplate(
getNamedParameterJdbcTemplate());
return template.queryForObject(SELECT_SUMMARY, CONVERSATION_MAPPER,
params);
} catch (EmptyResultDataAccessException erdae) {
return null;
}
}
示例3: loadMessageContent
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; //导入方法依赖的package包/类
public byte[] loadMessageContent(int id) throws DataAccessException {
try {
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue(ID, id, Types.INTEGER);
SimpleJdbcTemplate template = new SimpleJdbcTemplate(
getNamedParameterJdbcTemplate());
return template.queryForObject(SELECT_CONTENT, CONTENT_MAPPER,
params);
} catch (EmptyResultDataAccessException erdae) {
return null;
}
}
示例4: loadRequestHeader
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; //导入方法依赖的package包/类
public RequestHeader loadRequestHeader(int id) throws DataAccessException {
MapSqlParameterSource params = new MapSqlParameterSource();
try {
params.addValue(ID, id, Types.INTEGER);
SimpleJdbcTemplate template = new SimpleJdbcTemplate(
getNamedParameterJdbcTemplate());
return template.queryForObject(SELECT_REQUEST, REQUEST_MAPPER,
params);
} catch (EmptyResultDataAccessException erdae) {
return null;
}
}
示例5: loadResponseHeader
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; //导入方法依赖的package包/类
public MutableResponseHeader loadResponseHeader(int id)
throws DataAccessException {
try {
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue(ID, id, Types.INTEGER);
SimpleJdbcTemplate template = new SimpleJdbcTemplate(
getNamedParameterJdbcTemplate());
return template.queryForObject(SELECT_RESPONSE, RESPONSE_MAPPER,
params);
} catch (EmptyResultDataAccessException erdae) {
return null;
}
}
示例6: getUserPassword
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public String getUserPassword(String username) {
SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource);
Table table = AnnotationUtils.findAnnotation(User.class, Table.class);
return jdbcTemplate.queryForObject(
"select password from " + table.name() + " where username=?",
String.class, username);
}
示例7: findRedmineUser
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; //导入方法依赖的package包/类
/**
* Pesquisa usuario do redmine user
* @param login
* @return
*/
public RedmineUserVO findRedmineUser(String login){
SimpleJdbcTemplate simpleJdbcTemplate = getSimpleJdbcTemplate();
String redmineUserQuery = "select id,login,status from users where login = ? ";
RedmineUserVO user = simpleJdbcTemplate.queryForObject(redmineUserQuery, new RedmineUserRowMapper(), login);
return user;
}