Skip to content
Snippets Groups Projects
Commit 65bedc06 authored by Connor McCoy's avatar Connor McCoy
Browse files

Merge pull request #468 from kruthar/jdbc-scan-fix

[jdbc] added LIMIT to JDBC scan operation
parents d01e35ce 54fa0ea9
No related branches found
No related tags found
No related merge requests found
......@@ -304,8 +304,10 @@ public class JdbcDBClient extends DB implements JdbcDBClientConstants {
select.append(scanType.tableName);
select.append(" WHERE ");
select.append(PRIMARY_KEY);
select.append(" >= ");
select.append("?;");
select.append(" >= ?");
select.append(" ORDER BY ");
select.append(PRIMARY_KEY);
select.append(" LIMIT ?;");
PreparedStatement scanStatement = getShardConnectionByKey(key).prepareStatement(select.toString());
if (this.jdbcFetchSize != null) scanStatement.setFetchSize(this.jdbcFetchSize);
PreparedStatement stmt = cachedStatements.putIfAbsent(scanType, scanStatement);
......@@ -364,6 +366,7 @@ public class JdbcDBClient extends DB implements JdbcDBClientConstants {
scanStatement = createAndCacheScanStatement(type, startKey);
}
scanStatement.setString(1, startKey);
scanStatement.setInt(2, recordcount);
ResultSet resultSet = scanStatement.executeQuery();
for (int i = 0; i < recordcount && resultSet.next(); i++) {
if (result != null && fields != null) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment