org.springframework.jdbc.core.JdbcTemplate.queryForRowSet()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中org.springframework.jdbc.core.JdbcTemplate.queryForRowSet()方法的一些代码示例,展示了JdbcTemplate.queryForRowSet()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JdbcTemplate.queryForRowSet()方法的具体详情如下:
包路径:org.springframework.jdbc.core.JdbcTemplate
类名称:JdbcTemplate
方法名:queryForRowSet

JdbcTemplate.queryForRowSet介绍

暂无

代码示例

代码示例来源:origin: alibaba/fescar

/**
 * Test select for update with alias.
 */
@Test
public void testSelectForUpdateWithAlias() {
  RootContext.bind("mock.xid");
  jdbcTemplate.queryForRowSet("select a.name from user0 a where a.id = ? for update", new Object[] {1});
}

代码示例来源:origin: alibaba/fescar

/**
 * Test select for update.
 */
@Test
public void testSelectForUpdate() {
  RootContext.bind("mock.xid");
  jdbcTemplate.queryForRowSet("select a.name from user0 a where a.id = ? for update", new Object[] {1});
}

代码示例来源:origin: io.bufferslayer/buffer-spring-jdbc

public SqlRowSet queryForRowSet(String sql, Object[] args, int[] argTypes)
  throws DataAccessException {
 return delegate.queryForRowSet(sql, args, argTypes);
}

代码示例来源:origin: io.bufferslayer/bufferslayer-spring-jdbc

public SqlRowSet queryForRowSet(String sql, Object[] args, int[] argTypes)
  throws DataAccessException {
 return delegate.queryForRowSet(sql, args, argTypes);
}

代码示例来源:origin: stackoverflow.com

private static final String SQL_CREATE_TEST_DB = "CREATE DATABASE test";
private static final String SQL_PROD_TABLES = "SHOW TABLES IN production";

JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.execute(SQL_CREATE_TEST_DB);

SqlRowSet result = jdbcTemplate.queryForRowSet(SQL_PROD_TABLES);
while(result.next()) {
  String tableName = result.getString(result.getMetaData().getColumnName(1)); //Retrieves table name from column 1            
  jdbcTemplate.execute("CREATE TABLE test2." + tableName + " LIKE production." + tableName); //Create new table in test2 based on production structure
}

代码示例来源:origin: com.github.paulcwarren/spring-versions-jpa

@Override
  public boolean isLockOwner(Object entityId, Principal principal) {
    if (principal == null) {
      throw new SecurityException("no principal");
    }

    String sql = "SELECT entity_id from locks where entity_id = ? and lock_owner = ?";
    SqlRowSet rs = template.queryForRowSet(sql, entityId.toString(), principal.getName());
    return rs.next();
  }
}

代码示例来源:origin: dhis2/dhis2-core

@Override
public String validState()
{
  boolean hasData = jdbcTemplate.queryForRowSet( "select datasetid from completedatasetregistration limit 1" ).next();
  if ( !hasData )
  {
    return "No complete registrations exist, not updating completeness analytics tables";
  }
  return null;
}

代码示例来源:origin: dhis2/dhis2-core

@Override
public String validState()
{
  boolean hasData = jdbcTemplate.queryForRowSet( "select validationresultid from validationresult limit 1" ).next();
  if ( !hasData )
  {
    return "No validation results exist, not updating validation result analytics tables";
  }
  return null;
}

代码示例来源:origin: hekailiang/cloud-config

protected Date getDbDate() {
  try {
    return jdbcTemplate.queryForRowSet(dbDateSql, new Object[0]).getDate(1);
  } catch (Exception e) {
    return new Date();
  }
}

代码示例来源:origin: dhis2/dhis2-core

@Override
  public String validState()
  {
    boolean hasData = jdbcTemplate.queryForRowSet( "select dataelementid from trackedentitydatavalue limit 1" ).next();

    if ( !hasData )
    {
      return "No events exist, not updating event analytics tables";
    }

    return null;
  }
}

代码示例来源:origin: dhis2/dhis2-core

@Override
public boolean viewTableExists( String viewTableName )
{
  try
  {
    jdbcTemplate.queryForRowSet( "select * from " + statementBuilder.columnQuote( viewTableName ) + " limit 1" );
    return true;
  }
  catch ( BadSqlGrammarException ex )
  {
    return false; // View does not exist
  }
}

代码示例来源:origin: CESNET/perun

@Override
public boolean isObjectRelation(int templateId, Integer objectId) {
  logger.debug("IsObjectRelation for templateId: {}, objectId: {}", Arrays.asList(templateId, objectId));
  try {
    SqlRowSet rowSet = this.getJdbcTemplate().queryForRowSet("select * from pn_regex_object where regex_id = ? AND object_id = ?", templateId, objectId);
    logger.debug("Relation between templateId: {} and objectId: {}, found.", Arrays.asList(templateId, objectId));
    return rowSet.next();
  } catch (EmptyResultDataAccessException ex) {
    //This exception signals empty row
    logger.debug("Relation between templateId: {}, and objectId: {}, not found", Arrays.asList(templateId, objectId));
    return false;
  }
}

代码示例来源:origin: org.kuali.kfs/kfs-module-endow

/**
 * @see org.kuali.kfs.module.endow.batch.dataaccess.GLInterfaceBatchProcessDao#findDocumentTypes()
 */
public Collection<String> findDocumentTypes() {
  LOG.info("findDocumentTypes() started");
  
  Collection<String> documentTypes = new ArrayList<String>();
  
  SqlRowSet documentTypesRowSet = getJdbcTemplate().queryForRowSet("SELECT DISTINCT(DOC_TYP_NM) DOC_TYP_NM FROM END_TRAN_ARCHV_T ORDER BY DOC_TYP_NM"); 
  while (documentTypesRowSet.next()) {
    documentTypes.add(documentTypesRowSet.getString(EndowPropertyConstants.ColumnNames.GlInterfaceBatchProcessLine.TRANSACTION_ARCHIVE_DOC_TYP_NM));
  }
  
  LOG.info("findDocumentTypes() exited");
  
  return documentTypes;
}

代码示例来源:origin: org.tinygroup/tinydb

public int account(String sql) throws SQLException {
  int ret = 0;
  SqlRowSet sqlRowset = jdbcTemplate.queryForRowSet(sql);
  if (sqlRowset.next()) {
    ret = sqlRowset.getInt(1);
  }
  return ret;
}

代码示例来源:origin: CESNET/perun

private void removeOldPoolMessages(long olderThan) {
    Set<Integer> proccessedIds = new HashSet<Integer>();
    long actualTimeInMillis = new DateTime().getMillis();
    SqlRowSet srs = this.getJdbcTemplate().queryForRowSet("SELECT id,created FROM pn_pool_message");
    while (srs.next()) {
      Timestamp timeStamp = srs.getTimestamp("created");
      if (timeStamp.getTime() + olderThan < actualTimeInMillis) {
        proccessedIds.add(srs.getInt("id"));
      }
    }

    removeAllPoolMessages(proccessedIds);
  }
}

代码示例来源:origin: com.googlecode.metridoc/metridoc-camel-core

@Override
public SqlRowSet queryForRowSet(String query, int fetchSize) {
  JdbcTemplate jdbcTemplate = new StreamingJdbcTemplate();
  jdbcTemplate.setDataSource(dataSource);
  jdbcTemplate.setFetchSize(fetchSize);
  if(!query.startsWith("select")){
    query = "select * from " + query;
  }
  return jdbcTemplate.queryForRowSet(query);
}

代码示例来源:origin: dhis2/dhis2-core

@Override
public void populateSqlViewGrid( Grid grid, String sql )
{
  SqlRowSet rs = readOnlyJdbcTemplate.queryForRowSet( sql );
  
  int maxLimit = (Integer) systemSettingManager.getSystemSetting( SettingKey.SQL_VIEW_MAX_LIMIT );
  log.debug( "Get view SQL: " + sql + ", max limit: " + maxLimit );
  grid.addHeaders( rs );
  grid.addRows( rs, maxLimit );
}

代码示例来源:origin: org.tinygroup/org.tinygroup.tinydb

public int account(String sql) throws TinyDbException {
  try {
    int ret = 0;
    SqlRowSet sqlRowset = jdbcTemplate.queryForRowSet(sql);
    if (sqlRowset.next()) {
      ret = sqlRowset.getInt(1);
    }
    return ret;
  } catch (DataAccessException e) {
    throw new TinyDbException(e);
  }
}

代码示例来源:origin: EMCECS/ecs-sync

private SqlRowSet getRowSet(String id) {
  JdbcTemplate jdbcTemplate = dbService.getJdbcTemplate();
  SqlRowSet rowSet = jdbcTemplate.queryForRowSet("SELECT * FROM " + dbService.getObjectsTableName() + " WHERE source_id=?", id);
  rowSet.next();
  return rowSet;
}

代码示例来源:origin: EMCECS/ecs-sync

private void verifyDb(TestStorage storage) {
  JdbcTemplate jdbcTemplate = dbService.getJdbcTemplate();
  long totalCount = verifyDbObjects(jdbcTemplate, storage, storage.getRootObjects());
  SqlRowSet rowSet = jdbcTemplate.queryForRowSet("SELECT count(target_id) FROM " + AbstractDbService.DEFAULT_OBJECTS_TABLE_NAME + " WHERE target_id != ''");
  Assert.assertTrue(rowSet.next());
  Assert.assertEquals(totalCount, rowSet.getLong(1));
  jdbcTemplate.update("DELETE FROM " + AbstractDbService.DEFAULT_OBJECTS_TABLE_NAME);
}

相关文章