Java examples for JDBC:SQL Statement
Setting the Number of Rows to Prefetch When Executing a SQL Query
import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Main { public static void main(String[] argv) { try {// ww w. j a v a 2 s.c om Connection connection = null; // Get the fetch size of a statement Statement stmt = connection.createStatement(); int fetchSize = stmt.getFetchSize(); // Set the fetch size on the statement stmt.setFetchSize(100); // Create a result set ResultSet resultSet = stmt.executeQuery("SELECT * FROM my_table"); // Change the fetch size on the result set resultSet.setFetchSize(100); } catch (SQLException e) { } } }