本文整理汇总了Java中java.sql.ResultSet.relative方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.relative方法的具体用法?Java ResultSet.relative怎么用?Java ResultSet.relative使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.ResultSet
的用法示例。
在下文中一共展示了ResultSet.relative方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: advanceByRelative
import java.sql.ResultSet; //导入方法依赖的package包/类
private boolean advanceByRelative(ResultSet results, long offset) throws SQLException {
long diff = offset - position;
while (diff > Integer.MAX_VALUE) {
if (!results.relative(Integer.MAX_VALUE)) {
// Avoid updating position until relative succeeds.
position += Integer.MAX_VALUE;
return false;
}
// Avoid updating position until relative succeeds.
position += Integer.MAX_VALUE;
diff -= Integer.MAX_VALUE;
}
boolean ret = results.relative((int) diff);
// Make sure we only update the position after successfully calling relative(int).
position += diff;
return ret;
}
示例2: createSubEvents
import java.sql.ResultSet; //导入方法依赖的package包/类
private RowId createSubEvents(final String query, RowId rid, String tableName, boolean isChildQuery) throws SyncError {
logger.info("createSubEvents called with parameters : isChildQuery =" + isChildQuery + " , rid = " + rid
+ " , tableName = " + tableName + " , query = " + query);
PreparedStatement rowIdpstmt = null;
ResultSet rowIdSet = null;
RowId maxRid = null;
RowId minRid = null;
try {
rowIdpstmt = connection.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
if (isChildQuery) {
rowIdpstmt.setRowId(1, rid);
}
rowIdpstmt.setFetchSize(5000);
rowIdSet = rowIdpstmt.executeQuery();
rowIdSet.next();
minRid = rowIdSet.getRowId(1);
for (++subEventCount; subEventCount < (degree - 1); subEventCount++) {
rowIdSet.relative((int) optimalRange);
maxRid = rowIdSet.getRowId(1);
getSubEvent(minRid, maxRid, false);
minRid = maxRid;
fetchCount += optimalRange;
if (fetchCount > 1000000L) {
break;
}
}
if (subEventCount == (degree - 1)) {
rowIdSet.last();
maxRid = rowIdSet.getRowId(1);
getSubEvent(minRid, maxRid, true);
logger.info("Total subEvents created :" + eventCount);
}
} catch (Exception e) {
logger.error("Error while creating subEvents ", e);
throw new SyncError(e);
} finally {
DbResourceUtils.closeResources(rowIdSet, rowIdpstmt, null);
}
return maxRid;
}
示例3: createSubEvents
import java.sql.ResultSet; //导入方法依赖的package包/类
private RowId createSubEvents(String query, RowId rid, String tableName, boolean isChildQuery) throws SyncError{
logger.info("createSubEvents called with parameters : isChildQuery =" + isChildQuery + " , rid = " + rid
+ " , tableName = " + tableName + " , query = " + query);
PreparedStatement rowIdpstmt = null;
ResultSet rowIdSet = null;
RowId maxRid = null;
RowId minRid = null;
try {
rowIdpstmt = connection.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
if (isChildQuery) {
rowIdpstmt.setRowId(1, rid);
}
rowIdpstmt.setFetchSize(5000);
rowIdSet = rowIdpstmt.executeQuery();
rowIdSet.next();
minRid = rowIdSet.getRowId(1);
for (++subEventCount;subEventCount < (degree - 1); subEventCount++) {
rowIdSet.relative((int) optimalRange);
maxRid = rowIdSet.getRowId(1);
getSubEvent(minRid, maxRid, false);
minRid = maxRid;
fetchCount += optimalRange;
if (fetchCount > 1000000L) {
break;
}
}
if (subEventCount == (degree - 1)) {
rowIdSet.last();
maxRid = rowIdSet.getRowId(1);
getSubEvent(minRid, maxRid, true);
logger.info("Total subEvents created :" + eventCount);
}
} catch (Exception e) {
logger.error("Error while creating subEvents ", e);
throw new SyncError(e);
} finally {
DbResourceUtils.closeResources(rowIdSet, rowIdpstmt, null);
}
return maxRid;
}