Set the fetch size on the statement : Statement « Database « Java Tutorial

Home
Java Tutorial
1.Language
2.Data Type
3.Operators
4.Statement Control
5.Class Definition
6.Development
7.Reflection
8.Regular Expressions
9.Collections
10.Thread
11.File
12.Generics
13.I18N
14.Swing
15.Swing Event
16.2D Graphics
17.SWT
18.SWT 2D Graphics
19.Network
20.Database
21.Hibernate
22.JPA
23.JSP
24.JSTL
25.Servlet
26.Web Services SOA
27.EJB3
28.Spring
29.PDF
30.Email
31.J2ME
32.J2EE Application
33.XML
34.Design Pattern
35.Log
36.Security
37.Apache Common
38.Ant
39.JUnit
Java Tutorial » Database » Statement 
20.5.3.Set the fetch size on the statementPrevious/Next
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class Main {
  public static void main(String[] argvthrows Exception {

    String driverName = "com.jnetdirect.jsql.JSQLDriver";
    Class.forName(driverName);

    String serverName = "127.0.0.1";
    String portNumber = "1433";
    String mydatabase = serverName + ":" + portNumber;
    String url = "jdbc:JSQLConnect://" + mydatabase;
    String username = "username";
    String password = "password";

    Connection connection = DriverManager.getConnection(url, username, password);

    // 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);

  }
}
20.5.Statement
20.5.1.Change the fetch size on the result set
20.5.2.Get the fetch size of a statement
20.5.3.Set the fetch size on the statement
20.5.4.Retrieving All Rows from a Database Table
20.5.5.Getting Column Names from a database table in Java
20.5.6.Retrieve a rowcount from a ResultSet
20.5.7.Setting the Number of Rows to Prefetch When Executing a SQL Query
20.5.8.Create a result set
20.5.9.Creating a Database Table called my_table with one column, col_string, which holds strings.
20.5.10.Deleting a Database Table called my_table from a database.
20.5.11.Inserting a Row into a Database Table
20.5.12.Inserting a Row into a Database Table Using a Prepared Statement
20.5.13.Deleting a Row from a Database Table
20.5.14.Statement Batch Update
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.