how to set fetch size for jdbc odbc driver

Ads
 

how to set fetch size for jdbc odbc driver

What is the default fetch size for the JDBC ODBC driver and how can i fetch a set of results for JDBC ODBC driver?

View Answers

May 10, 2012 at 12:02 PM

Fetching results JDBC ODBC Driver

A. The default fetch size of JDBC drivers is 10. In general default fetch size of JDBC drivers is 10. To fetch small number of rows from database, JDBC driver is designed so that it may handle out of memory issues. When you set fetch size 100 , the number of network trips to database will become 10. Now you can see, the performance of your application is improved. So, If you want to retrieve large amount of data from table then set fetch size.

JDBC ODBC Fetch Example

package roseindia.net;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCsetFetchSize {
        public static void main(String[] args) throws SQLException {
                Connection con = null
                Statement stmt = null; 
                ResultSet rs = null;

                String conUrl = "jdbc:mysql://localhost:3306/";
                String driverName = "com.mysql.jdbc.Driver";
                String databaseName = "student";
                String usrName = "root";
                String usrPass = "root";
                try {
                        // Loading Driver
                        Class.forName(driverName). newInstance();
                } catch (ClassNotFoundException e) {
                        System.out.println(e.toString());
                }
                try {
                        // Getting Connection
                        con = DriverManager.getConnection(conUrl + databaseName, usrName,
                                        usrPass);
                        stmt = con.createStatement();
                         stmt.setFetchSize(100);

                        String query = "SELECT * FROM  student'";

                       rs= stmt.executeUpdate(query);
                   if (rs.next()) {
                System.out.println(rs.getString(1));
            }

                } catch (Exception e) {
                        System.out.println(e.toString());
                } finally {
                        // Closing Connection
                        con.close();
                        stmt.close();
                }
        }
}

Ads









Related Tutorials/Questions & Answers:
how to set fetch size for jdbc odbc driver
how to set fetch size for jdbc odbc driver  What is the default fetch size for the JDBC ODBC driver and how can i fetch a set of results for JDBC... table then set fetch size. JDBC ODBC Fetch Example package roseindia.net
How to Retrieve Excel data into mysql using type 2 JDBC-ODBC driver
How to Retrieve Excel data into mysql using type 2 JDBC-ODBC driver  ... Sources(ODBC) Open User DSN tab Add a user DSN Select Microsoft Excel Driver..."); Connection conn = DriverManager.getConnection("jdbc:odbc:excel
Advertisements
how to set size of button,textfield.
how to set size of button,textfield.  how we set size of button... large how to set as a preferd size in the panel or frame .when we click maximize button not effect on text or button to their of size the set on the prefered
JDBC-Odbc Connection
JDBC-ODBC Connection       JDBC-ODBC Connection is a JDBC driver that translates the operation... in explaining JDBC Odbc Connection in Java. The code explains you a how creation
jdbc odbc
jdbc odbc  i want to fetch the data from the ms access and print... connectivity.. the whole set up is perform only printing part is remaining? so help me how can i perform operation thanks in advanced
jdbc odbc
jdbc odbc  i want to fetch the data from the ms access and print... connectivity.. the whole set up is perform only printing part is remaining? so help me how can i perform operation thanks in advanced
How to download MySQL JDBC driver?
How to download MySQL JDBC driver?  Hi, What is JDBC Driver? How to download MySQL JDBC driver? Thanks   Hi, JDBC - Java database... program. To connect to MySQL database from Java program we need JDBC Driver of MySQL
jdbc odbc
= DriverManager.getConnection("jdbc:odbc:swing"); String sql = "INSERT...jdbc odbc  Sir, i want to get the selected value from JCombobox to ms...("JDBC All in One"); JComboBox petList = new JComboBox(petStrings
jdbc odbc
jdbc odbc   i have two tables in database 1table's attribute is foreign key of another in this case how to retrive value from both table and show in a gridview combine using java code   Sql query to retrieve values
JDBC-ODBC
JDBC-ODBC  HI what should i give names for DNS and TNS in Administrative Tools so that there will be connection between Database (oracle) and java.Actually how to operate Administrative Tools
JDBC-ODBC
JDBC-ODBC  HI what should i give names for DNS and TNS in Administrative Tools so that there will be connection between Database (oracle) and java.Actually how to operate Administrative Tools
How to set UILabel text size, color etc.. in XCode
How to set UILabel text size, color etc.. in XCode  How to set UILabel text size (height), color etc.. in XCode
Java JDBC ODBC
Java JDBC ODBC  What is the difference between JDBC and ODBC
JDBC-Odbc Connectivity
JDBC-ODBC Connectivity       The code illustrates an example from JDBC-ODBC...;"jdbc:odbc:emp";   public 
displaying output on web page immediately whent the jsp buffer size is full. And how to set jsp buffer size in bytes
displaying output on web page immediately whent the jsp buffer size is full. And how to set jsp buffer size in bytes  Here is my requirement, I have to display output on the browser after jsp buffer is full. And I have to set
JDBC ODBC Connection In Java
JDBC ODBC Connection In Java In this section we will read about the various aspects of JDBC ODBC such as, JDBC-ODBC bridge, JDBC ODBC connection, how... JDBC ODBC Bridge driver. The DSN (Data Source Name) specifies the connection
JDBC ODBC related problem
JDBC ODBC related problem  i WANT HELP RELATED TO JDBC CONNECTIVITY WITH MS ACCESS.. HERE IS MY FULL CODE... import java.awt.Container; import... con; con = DriverManager.getConnection("jdbc:odbc:Digambar
JDBC Driver - JDBC
JDBC Driver  What are the diffrent types of JDBC driver
Hibernate Criteria Fetch Size Example
Hibernate Criteria Fetch Size Example  I want example of Hibernate Criteria Fetch Size. Share me the best example program and tutorial of Hibernate Criteria Fetch Size. Thanks   Best Example of Hibernate Criteria Fetch
jdbc odbc sql server exception
jdbc odbc sql server exception  Hi, I am trying to use sql server with java jdbc odbc but I am getting this exception java.sql.SQLException: [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near '@P1
JDBC Fetch
JDBC Fetch       The Tutorial... we want to describe you an example from Jdbc Fetch. In this program code... a class Jdbc Fetch, Inside the main method we have the list of steps to be followed
JDBC Driver
JDBC Driver  I want to know the clear syntax and usages of $ types of JDBC drivers. Where can i get it? I search for it, nobody give Syntax for tat different drivers. can u give a sample codes for tat
how to connect java with ms access using odbc in eclipse
"); //Connection con = DriverManager.getConnection("jdbc:odbc:DRIVER={Microsoft...how to connect java with ms access using odbc in eclipse  import... = DriverManager.getConnection("jdbc:odbc:student.accdb"); Statement st
Hibernate Criteria Fetch Size
Hibernate Criteria Fetch Size Please consider the fetchSize example... static void main(String[] args) { int size = 4; Session session... = session.createCriteria(Student.class); criteria.setFetchSize(size); List list = criteria.list
maven mysql jdbc driver
maven mysql jdbc driver  How to add the maven mysql jdbc driver dependency in the pom.xml file of a maven based application?   Hi, Its simple!! Add the following into your pom.xml file: <dependency> <
type 4 jdbc driver
type 4 jdbc driver   i read in this site that type 4 jdbc driver is the fastest one so used it to connect with the database.......but not tried another drivers,....can u specifically answer me why type 4 is the fastest one
How Jdbc program can be run??
How Jdbc program can be run??  import java.sql.*; import java.util.... { Connection conn=DriverManager.getConnection("jdbc:odbc:advdsn1","student","myself...\jdk1.5.0\bin>java MyDbCode3 Enter bookid: 101 Sql Error:[Microsoft][ODBC Driver
JDBC Video Tutorial: How to download JDBC Driver for MySQL?
First thing to develop the JDBC program is to download the JDBC Driver... the MySQL database, so we have download the JDBC Driver for the MySQL. The website mysql.com is distributing the free version of the JDBC driver for the MySQL
jdbc type-4 driver
jdbc type-4 driver  I was tried the code that you give to run type-4 driver . import java.sql.*; import oracle.jdbc.driver.*; import oracle.sql.*; while compiling the error was like: package oracle.jdbc.odbc.driver does
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.  String sql = "UPDATE emp_details SET empEname = ?, emailId = ?, guid =?, proximityCard =?, managerEmailId = ?, reviewerEmailId
How To Use Database Driver
to interact with database. In JDBC there are four types Database driver Type 1: JDBC-ODBC Bridge driver Type 2: Native-API/partly Java driver Type 3... .style1 { text-align: center; } How To Use Database Driver Database

Ads