當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。