当前位置: 首页>>代码示例>>Java>>正文


Java JdbcTemplate.queryForList方法代码示例

本文整理汇总了Java中org.springframework.jdbc.core.JdbcTemplate.queryForList方法的典型用法代码示例。如果您正苦于以下问题:Java JdbcTemplate.queryForList方法的具体用法?Java JdbcTemplate.queryForList怎么用?Java JdbcTemplate.queryForList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.jdbc.core.JdbcTemplate的用法示例。


在下文中一共展示了JdbcTemplate.queryForList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: queryObjJoinDataByPageCondition

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
public List<Map<String, Object>> queryObjJoinDataByPageCondition(String innerSql, int start,int end, Object[] paramArray) {

		/*		JdbcTemplate jdbcTemplate = (JdbcTemplate) MicroDbHolder
		.getDbSource(dbName);*/
		JdbcTemplate jdbcTemplate = getMicroJdbcTemplate();
		String sql = "";
		String tempType=calcuDbType();
		if(tempType!=null && tempType.equals("mysql")){
		//if(dbType!=null && dbType.equals("mysql")){
			int pageRows=end-start;
			String limit=start+","+pageRows;
			sql=innerSql+ " limit "+limit;
		}else{
			String startLimit=" WHERE NHPAGE_RN >= "+start;
			String endLimit=" WHERE ROWNUM < "+end;
			sql="SELECT * FROM ( SELECT NHPAGE_TEMP.*, ROWNUM NHPAGE_RN FROM ("+ innerSql +" ) NHPAGE_TEMP "+endLimit+" ) "+ startLimit;
		}
		logger.debug(sql);
		logger.debug(Arrays.toString(paramArray));
		List<Map<String, Object>> retList = jdbcTemplate.queryForList(sql,paramArray);
		return retList;
	}
 
开发者ID:jeffreyning,项目名称:nh-micro,代码行数:23,代码来源:MicroMetaDao.java

示例2: queryObjDataPageByCondition

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
public List<Map<String, Object>> queryObjDataPageByCondition(String tableName, String condition,String cols,String orders, int start,int end ) {
	/*		JdbcTemplate jdbcTemplate = (JdbcTemplate) MicroDbHolder
	.getDbSource(dbName);*/
	JdbcTemplate jdbcTemplate = getMicroJdbcTemplate();
	String sql = "";
	String tempType=calcuDbType();
	if(tempType!=null && tempType.equals("mysql")){
	//if(dbType!=null && dbType.equals("mysql")){
		int pageRows=end-start;
		String limit=start+","+pageRows;
		sql="select "+cols+" from " + tableName + " where "+condition+" order by "+orders+ " limit "+limit;
	}else{
		String startLimit=" WHERE NHPAGE_RN >= "+start;
		String endLimit=" WHERE ROWNUM < "+end;
		String innerSql="select "+cols+" from " + tableName + " where "+condition+" order by "+orders;
		sql="SELECT * FROM ( SELECT NHPAGE_TEMP.*, ROWNUM NHPAGE_RN FROM ("+ innerSql +" ) NHPAGE_TEMP "+endLimit+" ) "+ startLimit;
	}
	logger.debug(sql);
	
	List<Map<String, Object>> retList = jdbcTemplate.queryForList(sql);
	return retList;
}
 
开发者ID:jeffreyning,项目名称:nh-micro,代码行数:23,代码来源:MicroMetaDao.java

示例3: locate

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
@Override
public PropertySource<?> locate(final Environment environment) {
    final Properties props = new Properties();

    try {
        final JdbcCloudConnection connection = new JdbcCloudConnection(environment);
        final DataSource dataSource = Beans.newDataSource(connection);
        final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
        final List<Map<String, Object>> rows = jdbcTemplate.queryForList(connection.getSql());
        for (final Map row : rows) {
            props.put(row.get("name"), row.get("value"));
        }
    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
    return new PropertiesPropertySource(getClass().getSimpleName(), props);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:18,代码来源:JdbcCloudConfigBootstrapConfiguration.java

示例4: initializeJiraDataBase

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
/**
 * Initialize data base with 'MDA' JIRA project.
 */
@BeforeClass
public static void initializeJiraDataBase() throws SQLException {
	datasource = new SimpleDriverDataSource(new JDBCDriver(), "jdbc:hsqldb:mem:dataSource", null, null);
	final Connection connection = datasource.getConnection();
	final JdbcTemplate jdbcTemplate = new JdbcTemplate(datasource);
	try {
		ScriptUtils.executeSqlScript(connection,
				new EncodedResource(new ClassPathResource("sql/base-1/jira-create.sql"), StandardCharsets.UTF_8));
		ScriptUtils.executeSqlScript(connection,
				new EncodedResource(new ClassPathResource("sql/base-1/jira.sql"), StandardCharsets.UTF_8));
		jdbcTemplate.queryForList("SELECT * FROM pluginversion WHERE ID = 10075");
	} finally {
		connection.close();
	}
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:19,代码来源:AbstractJiraTest.java

示例5: analyzeImpl

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
@Override
protected void analyzeImpl(DatabaseContext ctx) {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(ctx.getDataSource());
    String schemaName = ctx.getSchemaName();
    List<Map<String, Object>> foreignKeys = jdbcTemplate.queryForList(FOREIGN_KEY_QUERY, schemaName, schemaName);
    if (foreignKeys.size() > 0) {
        Issue issue = issueBuilder.builder()
            .type(getName())
            .weight(foreignKeys.size())
            .query(FOREIGN_KEY_QUERY)
            .dataSourceName(ctx.getDataSourceName())
            .weightUnit("idx")
            .description(buildDescription(foreignKeys))
            .build();
        issueRepository.addIssue(issue);
    }
}
 
开发者ID:EmbedITCZ,项目名称:dbadvisor,代码行数:18,代码来源:ForeignKeyAnalayzer.java

示例6: queryMetaBeanByCondition

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
public List<MicroMetaBean> queryMetaBeanByCondition(String tableName, String condition) {
	List<MicroMetaBean> retBeanList=new ArrayList();
	/*		JdbcTemplate jdbcTemplate = (JdbcTemplate) MicroDbHolder
	.getDbSource(dbName);*/
	JdbcTemplate jdbcTemplate = getMicroJdbcTemplate();
	String sql = "select * from " + tableName + " where "+condition;
	logger.debug(sql);
	List<Map<String, Object>> retList = jdbcTemplate.queryForList(sql);
	if(retList==null){
		return retBeanList;
	}
	
	for(Map<String,Object> rowMap:retList){
		MicroMetaBean metaBean = new MicroMetaBean();
		metaBean.setId((String) rowMap.get("id"));
		metaBean.setMeta_content((String) rowMap.get("meta_content"));
		metaBean.setMeta_key((String) rowMap.get("meta_key"));
		metaBean.setMeta_name((String) rowMap.get("meta_name"));
		metaBean.setMeta_type((String) rowMap.get("meta_type"));
		metaBean.setRemark((String) rowMap.get("remark"));
		metaBean.setCreate_time((Date) rowMap.get("create_time"));
		metaBean.setUpdate_time((Date) rowMap.get("update_time"));
		retBeanList.add(metaBean);
	}
	return retBeanList;
}
 
开发者ID:jeffreyning,项目名称:nh-micro,代码行数:27,代码来源:MicroMetaDao.java

示例7: getHeaderOfBlockWithMaxIndex

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
/**
 * return the block with the maximum value in the index column.
 *
 * @return the block with the maximum value in the index column.
 */
@Override
public Block getHeaderOfBlockWithMaxIndex() {
	synchronized (this) {
		if (closed) {
			return null;
		}
	}
	final JdbcTemplate t = new JdbcTemplate(ds);
	final String sql = getSql("getBlockWithMaxIndex");
	final List<byte[]> data = t.queryForList(sql, byte[].class);
	if (data.isEmpty()) {
		return null;
	}

	final Block block = new Block(ByteBuffer.wrap(data.get(0)));
	return block;
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:23,代码来源:BlockDbH2Impl.java

示例8: querySingleObjJoinByCondition

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
public Map<String, Object> querySingleObjJoinByCondition(String sql) {

		String tempType=calcuDbType();
		if(tempType!=null && tempType.equals("mysql")){
		//if(dbType!=null && dbType.equals("mysql")){
			sql=sql+" limit 1";
		}else{
			sql="select * from ("+sql+") where rownum=1";
		}	
		JdbcTemplate jdbcTemplate = getMicroJdbcTemplate();
		logger.debug(sql);
		List<Map<String, Object>> retList = jdbcTemplate.queryForList(sql);
		Map retMap=null;
		if(retList.size()>=1){
			retMap=retList.get(0);
		}
		return retMap;
	}
 
开发者ID:jeffreyning,项目名称:nh-micro,代码行数:19,代码来源:MicroMetaDao.java

示例9: getBlock

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
/**
 * returns the block with the given hash.
 *
 * @param hash
 *            the hash to use.
 * @param withTransactions
 *            if true, add transactions. If false, only return the block header.
 * @return the block with the given hash.
 */
private Block getBlock(final UInt256 hash, final boolean withTransactions) {
	synchronized (this) {
		if (closed) {
			return null;
		}
	}
	final JdbcTemplate t = new JdbcTemplate(ds);
	final String sql = getSql("getBlockWithHash");
	final List<byte[]> data = t.queryForList(sql, byte[].class, hash.toByteArray());
	if (data.isEmpty()) {
		return null;
	}

	final Block block = new Block(ByteBuffer.wrap(data.get(0)));
	if (withTransactions) {
		getTransactionsForBlock(block);
	}
	return block;
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:29,代码来源:BlockDbH2Impl.java

示例10: queryObjByCondition

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
public List<Map<String, Object>> queryObjByCondition(String tableName, String condition,String cols, String orders,Object[] paramArray) {

		/*		JdbcTemplate jdbcTemplate = (JdbcTemplate) MicroDbHolder
		.getDbSource(dbName);*/
		JdbcTemplate jdbcTemplate = getMicroJdbcTemplate();
		String sql = "select "+cols+" from " + tableName + " where "+condition+" order by "+orders;
		logger.debug(sql);
		logger.debug(Arrays.toString(paramArray));
		List<Map<String, Object>> retList = jdbcTemplate.queryForList(sql,paramArray);
		return retList;
	}
 
开发者ID:jeffreyning,项目名称:nh-micro,代码行数:12,代码来源:MicroMetaDao.java

示例11: getOwner

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
private String getOwner(final String appId) {
    final JdbcTemplate simpleJdbcTemplate = new JdbcTemplate(dataSource);
    final List<Map<String, Object>> results = simpleJdbcTemplate.queryForList(
            "SELECT unique_id FROM locks WHERE application_id=?", appId);
    if (results.isEmpty()) {
        return null;
    }
    return (String) results.get(0).get("unique_id");
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:10,代码来源:JpaLockingStrategyTests.java

示例12: getTransactionWithHash

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
@Override
public Transaction getTransactionWithHash(final UInt256 hash) {
	final JdbcTemplate t = new JdbcTemplate(ds);
	final String sql = getSql("getTransactionWithHash");
	final List<Map<String, Object>> dataList = t.queryForList(sql, hash.toByteArray());

	if (dataList.isEmpty()) {
		return null;
	}

	final Map<String, Object> data = dataList.get(0);

	final byte[] blockIndexBa = (byte[]) data.get("block_index");
	final byte[] transactionIndexBa = (byte[]) data.get(TRANSACTION_INDEX);
	final byte[] transactionBa = (byte[]) data.get("transaction");
	final int transactionIndex = getTransactionIndex(transactionIndexBa);

	final Transaction transaction = new Transaction(ByteBuffer.wrap(transactionBa));

	final Map<Integer, List<TransactionOutput>> outputsMap = getMapList(t,
			"getTransactionOutputsWithBlockAndTransactionIndex", new TransactionOutputMapToObject(), blockIndexBa,
			transactionIndexBa);
	transaction.outputs.addAll(outputsMap.get(transactionIndex));

	final Map<Integer, List<CoinReference>> inputsMap = getMapList(t,
			"getTransactionInputsWithBlockAndTransactionIndex", new CoinReferenceMapToObject(), blockIndexBa,
			transactionIndexBa);
	transaction.inputs.addAll(inputsMap.get(transactionIndex));

	final Map<Integer, List<Witness>> scriptsMap = getMapList(t,
			"getTransactionScriptsWithBlockAndTransactionIndex", new WitnessMapToObject(), blockIndexBa,
			transactionIndexBa);
	transaction.scripts.addAll(scriptsMap.get(transactionIndex));

	return transaction;
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:37,代码来源:BlockDbH2Impl.java

示例13: exportArticles

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
public void exportArticles(File dir, JdbcTemplate jdbcTemplate,
        String catalogId) throws Exception {
    String sql = "select id from CMS_ARTICLE where CATALOG_ID=?";
    List<Map<String, Object>> list = jdbcTemplate.queryForList(sql,
            catalogId);

    for (Map<String, Object> map : list) {
        String articleId = map.get("id").toString();
        new ArticleExporter().doExport(dir, jdbcTemplate, articleId);
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:12,代码来源:CatalogExporter.java

示例14: getWorflow

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
/**
 * Return workflow definition.
 * 
 * @param dataSource
 *            The data source of JIRA database.
 * @param workflow
 *            the workflow's name.
 * @return The workflow XML description.
 */
public String getWorflow(final DataSource dataSource, final String workflow) {
	final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
	final List<String> workflows = jdbcTemplate.queryForList("SELECT DESCRIPTOR FROM jiraworkflows WHERE workflowname=?", String.class, workflow);
	if (workflows.isEmpty()) {

		// Implicit 'jira' workflow case
		return null;
	}
	return workflows.get(0);
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:20,代码来源:JiraDao.java

示例15: queryObjJoinByCondition

import org.springframework.jdbc.core.JdbcTemplate; //导入方法依赖的package包/类
public List<Map<String, Object>> queryObjJoinByCondition(String sql,Object[] paramArray,int[] typeArray) {

		/*		JdbcTemplate jdbcTemplate = (JdbcTemplate) MicroDbHolder
		.getDbSource(dbName);*/
		JdbcTemplate jdbcTemplate = getMicroJdbcTemplate();
		logger.debug(sql);
		logger.debug(Arrays.toString(paramArray));
		List<Map<String, Object>> retList = jdbcTemplate.queryForList(sql,paramArray,typeArray);
		return retList;
	}
 
开发者ID:jeffreyning,项目名称:nh-micro,代码行数:11,代码来源:MicroMetaDao.java


注:本文中的org.springframework.jdbc.core.JdbcTemplate.queryForList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。