Results 1 to 4 of 4

Thread: Scrollable resultset in JAVA

  1. #1
    Join Date
    Nov 2009
    Posts
    712

    Scrollable resultset in JAVA

    Hi, Can anyone told me how to create the Scrollable Resultset with the help of java. When I use method to move the cursor of Resultset, where I want it told me that your Resultset is forwardonly. Can anyone help me. Please give reply as soon as possible, as my project gets stuck due to this error. Please reply me.
    Last edited by Adrina_g; 28-11-2009 at 02:01 PM.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Scrollable resultset in JAVA

    Hi, you can achieve this simply with the help of the following steps. Make use of it by copying that and then paste it in your code:

    Code:
    Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
    ResultSet rst = stmt.executeQuery("SELECT id, name FROM student");
    It will solve your problem.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Scrollable resultset in JAVA

    Hi, I have a source code which will help you to move the Cursor in a Scrollable Result Set. This code will also help you with different methods to use the resultset.

    Code:
    try 
    {
    Statement stmt = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
    ResultSet resultSet = stmt.executeQuery("SELECT * FROM emp");
    while (resultSet.next()) 
    {
    String s = resultSet.getString(1);
    }
    while (resultSet.previous()) 
    {
    String s = resultSet.getString(1);
    }
    resultSet.first();
    resultSet.last();
    resultSet.afterLast();
    resultSet.beforeFirst();
    resultSet.absolute(5);
    resultSet.absolute(8);
    resultSet.absolute(-5);
    resultSet.relative(5);
    resultSet.relative(3);
    } 
    catch (SQLException e) 
    {
    }

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Scrollable resultset in JAVA

    Hi, you want to scroll your resultset with the help of java. So, first determine whether your database Supports Scrollable Result Set or not. A scrollable result set allows the cursor to be moved to any row in the result set. This capability is useful for GUI tools that browse result sets.

    Code:
    try 
    {
    DatabaseMetaData dm = connection.getMetaData();
    if (dm.supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE)) 
    {
    }
    if (dm.supportsResultSetType(ResultSet.TYPE_SCROLL_SENSITIVE)) 
    {
    }
    if (!dm.supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE) && !dm.supportsResultSetType(ResultSet.TYPE_SCROLL_SENSITIVE)) 
    {          
    }
    } 
    catch (SQLException e) 
    {
    }
    If it is supporting it then just make use of following code to make it Scrollable.
    Code:
    Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
    ResultSet rst = stmt.executeQuery("SELECT id, name FROM student");

Similar Threads

  1. Replies: 4
    Last Post: 04-09-2013, 11:04 PM
  2. Replies: 5
    Last Post: 05-04-2010, 11:00 AM
  3. A scrollable PictureBox in C#
    By ramsun in forum Software Development
    Replies: 5
    Last Post: 13-02-2010, 07:32 PM
  4. Link List Example in Java Sample program in Java
    By trickson in forum Software Development
    Replies: 2
    Last Post: 04-08-2009, 08:23 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,714,825.90858 seconds with 16 queries