Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Some help with MySQL fetch size

807589Jul 31 2008 — edited Jul 31 2008
To get the number of rows returned by a MySQL query, I do this:
public static void main(String[] args) throws Exception
    {
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        Connection connection = DriverManager.getConnection(url, user, password);
        Statement statement = connection.createStatement();
        String query = "SELECT * FROM users";
        ResultSet rs = statement.executeQuery(query);

        int number = statement.getFetchSize();
        connection.close();
        System.out.print(number);
    }
which returns 0 even though I have 7 users. What am I doing wrong?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 28 2008
Added on Jul 31 2008
5 comments
895 views