本文整理汇总了Java中org.springframework.jdbc.core.JdbcTemplate.queryForMap方法的典型用法代码示例。如果您正苦于以下问题:Java JdbcTemplate.queryForMap方法的具体用法?Java JdbcTemplate.queryForMap怎么用?Java JdbcTemplate.queryForMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.jdbc.core.JdbcTemplate
的用法示例。
在下文中一共展示了JdbcTemplate.queryForMap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exportCatalog
import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
public File exportCatalog(File baseDir, JdbcTemplate jdbcTemplate,
String catalogId) throws Exception {
String sql = "select id, code, name from CMS_CATALOG where id=?";
Map<String, Object> map = jdbcTemplate.queryForMap(sql, catalogId);
String code = (String) map.get("code");
String name = (String) map.get("name");
File dir = new File(baseDir, code);
dir.mkdirs();
File file = new File(baseDir, code + ".properties");
PrintWriter writer = new PrintWriter(new OutputStreamWriter(
new FileOutputStream(file), "UTF-8"));
writer.println("code=" + code);
writer.println("name=" + name);
writer.flush();
writer.close();
return dir;
}
示例2: getMetaBeanById
import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
public MicroMetaBean getMetaBeanById(String tableName, String id) {
/* JdbcTemplate jdbcTemplate = (JdbcTemplate) MicroDbHolder
.getDbSource(dbName);*/
JdbcTemplate jdbcTemplate = getMicroJdbcTemplate();
String sql = "select * from " + tableName + " where id=?";
logger.debug(sql);
logger.debug("["+id+"]");
Map retMap = jdbcTemplate.queryForMap(sql, id);
MicroMetaBean metaBean = new MicroMetaBean();
metaBean.setId((String) retMap.get("id"));
metaBean.setMeta_content((String) retMap.get("meta_content"));
metaBean.setMeta_key((String) retMap.get("meta_key"));
metaBean.setMeta_name((String) retMap.get("meta_name"));
metaBean.setMeta_type((String) retMap.get("meta_type"));
metaBean.setRemark((String) retMap.get("remark"));
metaBean.setCreate_time((Date) retMap.get("create_time"));
metaBean.setUpdate_time((Date) retMap.get("update_time"));
return metaBean;
}
示例3: doExport
import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
public void doExport(File baseDir, JdbcTemplate jdbcTemplate,
String articleId) throws Exception {
try {
String sql = "select id,code,title,content from CMS_ARTICLE where id=?";
Map<String, Object> map = jdbcTemplate.queryForMap(sql, articleId);
this.exportProperties(baseDir, map);
this.exportContent(baseDir, map);
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("cannot find article : " + articleId);
}
}