當前位置: 首頁>>代碼示例>>Java>>正文


Java SqlRowSet類代碼示例

本文整理匯總了Java中org.springframework.jdbc.support.rowset.SqlRowSet的典型用法代碼示例。如果您正苦於以下問題:Java SqlRowSet類的具體用法?Java SqlRowSet怎麽用?Java SqlRowSet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SqlRowSet類屬於org.springframework.jdbc.support.rowset包,在下文中一共展示了SqlRowSet類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: selectparentFolders

import org.springframework.jdbc.support.rowset.SqlRowSet; //導入依賴的package包/類
@Override
@Transactional
public List<Long> selectparentFolders(List<Long> nodesid) throws SaodException {
	if (nodesid == null || nodesid.size() == 0) {
		return Collections.emptyList();
	}

	NamedParameterJdbcTemplate jdbcNamesTpl = new NamedParameterJdbcTemplate(this.jdbcTemplate);

	MapSqlParameterSource parameters = new MapSqlParameterSource();
	parameters.addValue("ids", nodesid);

	String query = sqlQueries.getQuery("select_parents_folders.sql");
	final SqlRowSet queryForRowSet = jdbcNamesTpl.queryForRowSet(query, parameters);

	final List<Long> ids = new ArrayList<>();
	while (queryForRowSet.next()) {
		ids.add(queryForRowSet.getLong(1));
	}

	return ids;
}
 
開發者ID:jeci-sarl,項目名稱:stats-alfresco-on-database,代碼行數:23,代碼來源:LocalDaoImpl.java

示例2: removeDuplicateRows

import org.springframework.jdbc.support.rowset.SqlRowSet; //導入依賴的package包/類
private void removeDuplicateRows(final JdbcTemplate jdbcTemplate, final Long zone) {
    final List<SubjectEntity> subjects = jdbcTemplate
            .query("SELECT DISTINCT subject_identifier, attributes FROM subject", new SubjectRowMapper());
    jdbcTemplate.update("DELETE FROM subject *");
    for (SubjectEntity s : subjects) {
        jdbcTemplate.update("INSERT INTO subject (subject_identifier, attributes, "
                        + " authorization_zone_id) VALUES (?,?,?)", s.getSubjectIdentifier(), s
                        .getAttributesAsJson(),
                zone);
    }
    final List<ResourceEntity> resources = jdbcTemplate
            .query("SELECT DISTINCT resource_identifier, attributes FROM resource", new ResourceRowMapper());
    jdbcTemplate.update("DELETE FROM resource *");
    for (ResourceEntity r : resources) {
        jdbcTemplate.update("INSERT INTO resource (resource_identifier, attributes, "
                        + " authorization_zone_id) VALUES (?,?,?)", r.getResourceIdentifier(), r
                        .getAttributesAsJson(),
                zone);
    }

    final List<PolicySetEntity> policysets = jdbcTemplate
            .query("SELECT DISTINCT policy_set_id, policy_set_json FROM policy_set", new PolicySetRowMapper());
    jdbcTemplate.update("DELETE FROM policy_set *");
    for (PolicySetEntity ps : policysets) {
        SqlRowSet row = jdbcTemplate
                .queryForRowSet("SELECT * FROM policy_set WHERE policy_set_id =?", ps.getPolicySetID());
        if (row.next()) {
            jdbcTemplate.update("UPDATE policy_set SET policy_set_json = ? WHERE policy_set_id = ?",
                    ps.getPolicySetJson(), ps.getPolicySetID());
        } else {
            jdbcTemplate.update("INSERT INTO policy_set (policy_set_id, policy_set_json, "
                    + " authorization_zone_id) VALUES (?,?,?)", ps.getPolicySetID(), ps.getPolicySetJson(), zone);
        }
    }
}
 
開發者ID:eclipse,項目名稱:keti,代碼行數:36,代碼來源:V2_0_1__InitializeIdentityZones.java

示例3: dumpAfnemerindicatieTabelNaarFile

import org.springframework.jdbc.support.rowset.SqlRowSet; //導入依賴的package包/類
@Override
public void dumpAfnemerindicatieTabelNaarFile(final File outputFile) {
    LOGGER.info("Genereer afnemerindicatie rijen naar {}", outputFile.getAbsolutePath());
    try (FileOutputStream fos = new FileOutputStream(outputFile)) {
        final SqlRowSet sqlRowSet = new JdbcTemplate(masterDataSource).queryForRowSet("select * from autaut.persafnemerindicatie where levsautorisatie "
                + "IN (select id from autaut.levsautorisatie where dateinde is null)");
        while (sqlRowSet.next()) {
            IOUtils.write(String.format("%s,%s,%s,%s,%s,%s,%s%n",
                    sqlRowSet.getString(INDEX_ID),
                    sqlRowSet.getString(INDEX_PERS),
                    sqlRowSet.getString(INDEX_AFNEMER),
                    sqlRowSet.getString(INDEX_LEVSAUTORISATIE),
                    StringUtils.defaultIfEmpty(sqlRowSet.getString(INDEX_DATAANVANGMATERIELEPERIODE), AfnemerindicatieConversie.NULL_VALUE),
                    StringUtils.defaultIfEmpty(sqlRowSet.getString(INDEX_DATEINDEVOLGEN), AfnemerindicatieConversie.NULL_VALUE),
                    sqlRowSet.getString(INDEX_INDAG)
            ), fos, StandardCharsets.UTF_8);
        }
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:22,代碼來源:AfnemerindicatieBatchStrategy.java

示例4: dumpHisAfnemerindicatieTabel

import org.springframework.jdbc.support.rowset.SqlRowSet; //導入依賴的package包/類
@Override
public void dumpHisAfnemerindicatieTabel(final File outputFile) {
    LOGGER.info("Genereer hisafnemerindicatie rijen naar {}", outputFile.getAbsolutePath());
    try (FileOutputStream fos = new FileOutputStream(outputFile)) {
        final SqlRowSet sqlRowSet = new JdbcTemplate(masterDataSource).queryForRowSet("select hpa.* from autaut.his_persafnemerindicatie hpa\n"
                + "inner join (select pa.id as afnemerindid \n"
                + "from autaut.persafnemerindicatie pa, autaut.levsautorisatie la where pa.levsautorisatie = la.id and la.dateinde is null) \n"
                + "as x on hpa.persafnemerindicatie = x.afnemerindid");
        while (sqlRowSet.next()) {
            IOUtils.write(String.format("%s,%s,%s,%s,%s,%s,%s,%s%n",
                    sqlRowSet.getString(INDEX_HIS_ID),
                    sqlRowSet.getString(INDEX_HIS_PERSAFNEMERINDICATIE),
                    sqlRowSet.getString(INDEX_HIS_TSREG),
                    StringUtils.defaultIfBlank(sqlRowSet.getString(INDEX_HIS_TSVERVAL), AfnemerindicatieConversie.NULL_VALUE),
                    StringUtils.defaultIfBlank(sqlRowSet.getString(INDEX_HIS_DIENSTINHOUD), AfnemerindicatieConversie.NULL_VALUE),
                    StringUtils.defaultIfBlank(sqlRowSet.getString(INDEX_HIS_DIENSTVERVAL), AfnemerindicatieConversie.NULL_VALUE),
                    StringUtils.defaultIfBlank(sqlRowSet.getString(INDEX_HIS_DATAANVANGMATERIELEPERIODE), AfnemerindicatieConversie.NULL_VALUE),
                    StringUtils.defaultIfBlank(sqlRowSet.getString(INDEX_HIS_DATEINDEVOLGEN), AfnemerindicatieConversie.NULL_VALUE)
            ), fos, StandardCharsets.UTF_8);
        }
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:25,代碼來源:AfnemerindicatieBatchStrategy.java

示例5: loadRow

import org.springframework.jdbc.support.rowset.SqlRowSet; //導入依賴的package包/類
@Override
@Transactional
public PrintNode loadRow(Long nodeid) throws SaodException {
	String query = sqlQueries.getQuery("select_row_node_id.sql");
	final SqlRowSet queryForRowSet = this.jdbcTemplate.queryForRowSet(query, nodeid);

	while (queryForRowSet.next()) {
		PrintNode node = new PrintNode(nodeid);
		node.setParent(queryForRowSet.getLong(2));
		node.setLocalSize(queryForRowSet.getLong(3));
		node.setDirSize(queryForRowSet.getLong(4));
		return node;
	}

	return null;
}
 
開發者ID:jeci-sarl,項目名稱:stats-alfresco-on-database,代碼行數:17,代碼來源:LocalDaoImpl.java

示例6: selectParentNodeId

import org.springframework.jdbc.support.rowset.SqlRowSet; //導入依賴的package包/類
@Override
@Transactional
public Map<Long, Long> selectParentNodeId(List<Long> child_id) throws SaodException {
	NamedParameterJdbcTemplate jdbcNamesTpl = new NamedParameterJdbcTemplate(this.jdbcTemplate);

	final String query = sqlQueries.getQuery("select_parent_node_id.sql");
	final Map<Long, Long> libelle = new HashMap<>();

	for (int i = 0; i < child_id.size(); i += MAX_NUM_EXP_LIST) {
		MapSqlParameterSource parameters = new MapSqlParameterSource();
		parameters.addValue("ids", child_id.subList(i, Math.min(i + MAX_NUM_EXP_LIST, child_id.size())));

		final SqlRowSet queryForRowSet = jdbcNamesTpl.queryForRowSet(query, parameters);
		while (queryForRowSet.next()) {
			libelle.put(queryForRowSet.getLong(1), queryForRowSet.getLong(2));
		}

	}

	return libelle;
}
 
開發者ID:jeci-sarl,項目名稱:stats-alfresco-on-database,代碼行數:22,代碼來源:AlfrescoDaoImpl.java

示例7: getAllUsers

import org.springframework.jdbc.support.rowset.SqlRowSet; //導入依賴的package包/類
/**
 * getAllUsers
 */
public List<User> getAllUsers() {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    List<User> userList = new ArrayList<User>();
    SqlRowSet rowset = jdbcTemplate.queryForRowSet("select * from users_auto");

    while (rowset.next()) {
        User user = new User();
        user.setId(rowset.getInt("ID"));
        user.setName(rowset.getString("NAME"));
        user.setMail(rowset.getString("MAIL"));
        userList.add(user);
    }

    return userList;
}
 
開發者ID:Eulbobo,項目名稱:java-samples,代碼行數:19,代碼來源:JdbcInsertUsageWithSequenceTest.java

示例8: updatePasswordLastUpdated

import org.springframework.jdbc.support.rowset.SqlRowSet; //導入依賴的package包/類
private void updatePasswordLastUpdated()
{
    try
    {
        String timestamp = DateUtils.getLongDateString();

        SqlRowSet resultSet = jdbcTemplate.queryForRowSet( "SELECT * from users WHERE passwordlastupdated IS NULL" );

        while ( resultSet.next() )
        {
            String sql = "UPDATE users SET passwordlastupdated = '" + timestamp + "' WHERE passwordlastupdated IS NULL";
            jdbcTemplate.update( sql );
        }
    }
    catch ( Exception ex ) // Log and continue
    {
        log.error( "Problem updating passwordLastUpdated on table user: " + ex.getMessage() );
    }
}
 
開發者ID:dhis2,項目名稱:dhis2-core,代碼行數:20,代碼來源:IdentityPopulator.java

示例9: getRectangle

import org.springframework.jdbc.support.rowset.SqlRowSet; //導入依賴的package包/類
@Override
public Rectangle getRectangle( EventQueryParams params )
{
    String clusterField = params.getCoordinateField();
    String quotedClusterField = statementBuilder.columnQuote( clusterField );
            
    String sql = "select count(psi) as " + COL_COUNT + ", ST_Extent(" + quotedClusterField + ") as " + COL_EXTENT + " ";
    
    sql += getFromWhereClause( params );

    log.debug( String.format( "Analytics event count and extent SQL: %s", sql ) );
    
    Rectangle rectangle = new Rectangle();
    
    SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
    
    if ( rowSet.next() )
    {
        Object extent = rowSet.getObject( COL_EXTENT );
        
        rectangle.setCount( rowSet.getLong( COL_COUNT ) );
        rectangle.setExtent( extent != null ? String.valueOf( rowSet.getObject( COL_EXTENT ) ) : null );
    }
    
    return rectangle;
}
 
開發者ID:dhis2,項目名稱:dhis2-core,代碼行數:27,代碼來源:JdbcEventAnalyticsManager.java

示例10: addRows

import org.springframework.jdbc.support.rowset.SqlRowSet; //導入依賴的package包/類
@Override
public Grid addRows( SqlRowSet rs )
{
    int cols = rs.getMetaData().getColumnCount();

    while ( rs.next() )
    {
        addRow();

        for ( int i = 1; i <= cols; i++ )
        {
            addValue( rs.getObject( i ) );
        }
    }

    return this;
}
 
開發者ID:dhis2,項目名稱:dhis2-core,代碼行數:18,代碼來源:ListGrid.java

示例11: lookupName

import org.springframework.jdbc.support.rowset.SqlRowSet; //導入依賴的package包/類
/**
 * Convert a name to an object identifier.
 * <p>
 * If an object is renamed, the old name remains as an alias.
 * The separate name resolution handles that case.
 * 
 * @param name  the name, not null
 * @param onDeleted  how to handle deletion
 * @return the object identifier, null if not found
 */
ObjectId lookupName(String name, OnDeleted onDeleted) {
  ArgumentChecker.notNull(name, "name");
  try (Timer.Context context = _lookupNameTimer.time()) {
    final DbMapSqlParameterSource args = createParameterSource()
      .addValue("name_ci", caseInsensitive(name));
    final NamedParameterJdbcOperations namedJdbc = getDbConnector().getJdbcTemplate();
    final String sql = getElSqlBundle().getSql("GetIdByName", args);
    SqlRowSet rowSet = namedJdbc.queryForRowSet(sql, args);
    if (rowSet.next() == false) {
      throw new DataNotFoundException("Name not found: " + name);
    }
    String deleted = rowSet.getString("DELETED");
    if (deleted.equals("Y")) {
      if (onDeleted == OnDeleted.RETURN_NULL) {
        return null;
      } else if (onDeleted == OnDeleted.EXCEPTION) {
        throw new DataNotFoundException("Name not found: " + name);
      }
    }
    return createObjectId(rowSet.getLong("DOC_ID")).getObjectId();
  }
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:33,代碼來源:AbstractDbUserMaster.java

示例12: dump

import org.springframework.jdbc.support.rowset.SqlRowSet; //導入依賴的package包/類
private static void dump(String sql) {
    logger.fine("\n" + sql);
    SqlRowSet rs = dao.getJdbcTemplate().queryForRowSet(sql);
    try {
        SqlRowSetMetaData rsmd = rs.getMetaData();
        int c = rsmd.getColumnCount();
        StringBuffer buff = new StringBuffer();
        for (int i = 1; i <= c; i++) {
            buff.append(rsmd.getColumnLabel(i));
            buff.append(i == c ? "\n" : "\t");
        }
        logger.fine(buff.toString());
        buff.delete(0, buff.length());
        while (rs.next()) {
            for (int i = 1; i <= c; i++) {
                buff.append(rs.getObject(i));
                buff.append(i == c ? "\n" : "\t");
            }
            logger.fine(buff.toString());
            buff.delete(0, buff.length());
        }
        logger.fine("================\n\n");
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:intuit,項目名稱:Tank,代碼行數:27,代碼來源:JdbcMessageDAOTest.java

示例13: streamQuery

import org.springframework.jdbc.support.rowset.SqlRowSet; //導入依賴的package包/類
public <T> T streamQuery(String sql, Function<Stream<SqlRow>, ? extends T> streamer, Object... args) {
    return query(sql, resultSet -> {
        final SqlRowSet rowSet = new ResultSetWrappingSqlRowSet(resultSet);
        final SqlRow sqlRow = new SqlRowAdapter(rowSet);

        Supplier<Spliterator<SqlRow>> supplier = () -> Spliterators.spliteratorUnknownSize(new Iterator<SqlRow>() {
            @Override
            public boolean hasNext() {
                return !rowSet.isLast();
            }

            @Override
            public SqlRow next() {
                if (!rowSet.next()) {
                    throw new NoSuchElementException();
                }
                return sqlRow;
            }
        }, Spliterator.IMMUTABLE);
        return streamer.apply(StreamSupport.stream(supplier, Spliterator.IMMUTABLE, false));

    }, args);
}
 
開發者ID:APNIC-net,項目名稱:spring-jdbctemplate-streams,代碼行數:24,代碼來源:JdbcStream.java

示例14: stream

import org.springframework.jdbc.support.rowset.SqlRowSet; //導入依賴的package包/類
public Stream<SqlRow> stream() throws SQLException {
    final SqlRowSet rowSet = new ResultSetWrappingSqlRowSet(preparedStatement.executeQuery());
    final SqlRow sqlRow = new SqlRowAdapter(rowSet);

    Supplier<Spliterator<SqlRow>> supplier = () -> Spliterators.spliteratorUnknownSize(new Iterator<SqlRow>() {
        @Override
        public boolean hasNext() {
            return !rowSet.isLast();
        }

        @Override
        public SqlRow next() {
            if (!rowSet.next()) {
                throw new NoSuchElementException();
            }
            return sqlRow;
        }
    }, Spliterator.IMMUTABLE);
    return StreamSupport.stream(supplier, Spliterator.IMMUTABLE, false);
}
 
開發者ID:APNIC-net,項目名稱:spring-jdbctemplate-streams,代碼行數:21,代碼來源:JdbcStream.java

示例15: listFields

import org.springframework.jdbc.support.rowset.SqlRowSet; //導入依賴的package包/類
public List<CmsField> listFields(String tablename) {
	String sql = " desc  " + tablename;
	List<CmsField> fields = new ArrayList<CmsField>();
	SqlRowSet set = getJdbcTemplate().queryForRowSet(sql);
	while (set.next()) {
		CmsField field = new CmsField();
		field.setName(set.getString(1));
		field.setFieldType(set.getString(2));
		field.setNullable(set.getString(3));
		field.setFieldProperty(set.getString(4));
		field.setFieldDefault(set.getString(5));
		field.setExtra(set.getString(6));
		fields.add(field);
	}
	return fields;
}
 
開發者ID:huanzhou,項目名稱:jeecms6,代碼行數:17,代碼來源:CmsMysqlDataBackDaoImpl.java


注:本文中的org.springframework.jdbc.support.rowset.SqlRowSet類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。