java.sql.ResultSet#setFetchDirection ( )源码实例Demo

下面列出了java.sql.ResultSet#setFetchDirection ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: CloverETL-Engine   文件: FirebirdSpecific.java
@Override
public void optimizeResultSet(ResultSet resultSet,
		OperationType operationType) {

	switch (operationType){
	case READ:
		try {
			resultSet.setFetchDirection(ResultSet.FETCH_FORWARD);
			// SQLite driver MUST HAVE fetch size set to 0 - otherwise it limits number of results returned
			resultSet.setFetchSize(0);
		} catch(SQLException ex) {
			//TODO: for now, do nothing
		}
	}

}
 
源代码2 项目: CloverETL-Engine   文件: SQLiteSpecific.java
@Override
public void optimizeResultSet(ResultSet resultSet,
		OperationType operationType) {

	switch (operationType){
	case READ:
		try {
			resultSet.setFetchDirection(ResultSet.FETCH_FORWARD);
			// SQLite driver MUST HAVE fetch size set to 0 - otherwise it limits number of results returned
			resultSet.setFetchSize(0);
		} catch(SQLException ex) {
			//TODO: for now, do nothing
		}
	}

}
 
@Override
public final void setFetchDirection(final int direction) throws SQLException {
    Collection<SQLException> exceptions = new LinkedList<>();
    for (ResultSet each : resultSets) {
        try {
            each.setFetchDirection(direction);
        } catch (final SQLException ex) {
            exceptions.add(ex);
        }
    }
    throwSQLExceptionIfNecessary(exceptions);
}
 
源代码4 项目: Openfire   文件: DbConnectionManager.java
/**
 * Scrolls forward in a result set the specified number of rows. If the JDBC driver
 * supports the feature, the cursor will be moved directly. Otherwise, we scroll
 * through results one by one manually by calling {@code rs.next()}.
 *
 * @param rs the ResultSet object to scroll.
 * @param rowNumber the row number to scroll forward to.
 * @throws SQLException if an error occurs.
 */
public static void scrollResultSet(ResultSet rs, int rowNumber) throws SQLException {
    // If the driver supports scrollable result sets, use that feature.
    if (isScrollResultsSupported()) {
        if (rowNumber > 0) {
            // We will attempt to do a relative fetch. This may fail in SQL Server if
            // <resultset-navigation-strategy> is set to absolute. It would need to be
            // set to looping to work correctly.
            // If so, manually scroll to the correct row.
            try {
                rs.setFetchDirection(ResultSet.FETCH_FORWARD);
                rs.relative(rowNumber);
            }
            catch (SQLException e) {
                // TODO change "Error ..." to "Disabling ..."
                Log.error("Error in JDBC method rs.relative(rowNumber).", e);
                //Log.error("Disabling JDBC method rs.relative(rowNumber).", e);
                //scrollResultsSupported = false;
                for (int i = 0; i < rowNumber; i++) {
                    rs.next();
                }
            }
        }
    }
    // Otherwise, manually scroll to the correct row.
    else {
        for (int i = 0; i < rowNumber; i++) {
            rs.next();
        }
    }
}
 
源代码5 项目: CloverETL-Engine   文件: AbstractJdbcSpecific.java
@Override
public void optimizeResultSet(ResultSet resultSet, OperationType operationType) {
	switch (operationType){
	case READ:
		try {
			resultSet.setFetchDirection(ResultSet.FETCH_FORWARD);
			resultSet.setFetchSize(DEFAULT_FETCH_SIZE);
		} catch(SQLException ex) {
			//TODO: for now, do nothing
		}
	}
}
 
源代码6 项目: CloverETL-Engine   文件: MySQLSpecific.java
@Override
public void optimizeResultSet(ResultSet res,OperationType operType){
	if (operType == OperationType.READ) {
		try {
			res.setFetchDirection(ResultSet.FETCH_FORWARD);
		}catch(SQLException ex){
			//TODO: for now, do nothing
		}
	}
}
 
源代码7 项目: spotbugs   文件: SQL_BAD_RESULTSET_ACCESS.java
@NoWarning("SQL_BAD_RESULTSET_ACCESS")
void notBug2(ResultSet any) throws SQLException {
    any.setFetchDirection(0);
}