The cursor in scrollable resultset

The cursor in scrollable resultset

How to move the cursor in scrollable resultset ?

View Answers

November 13, 2010 at 12:35 PM

Hi friends,

With the help of this example, you can understands how to move cursor in scrollable Result set.

java.sql.*;

public class ScrollableCursor {

public static void main(String[] args) {

try {
    String mysqlDriver = "com.mysql.jdbc.Driver";
    Class.forName(mysqlDriver).newInstance();
    // Connection String
    String connectionString = "jdbc:mysql://192.168.10.13:3306/studentinformation";
    String username = "root";
    String password = "root";
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    con = DriverManager.getConnection(connectionString, username,
            password);
    // Create scrollable Result Set. 
    stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
            ResultSet.CONCUR_READ_ONLY);
    String sqlString = "Select * from s_infor;";
    rs = stmt.executeQuery(sqlString);
    System.out
    .println("---------Student Information(Forword)----------");
    while (rs.next()) {
        int roll = rs.getInt("s_Roll");
        String Name = rs.getString("s_Name");
        String Address = rs.getString("s_Address");
        System.out.println(roll + "  " + Name + "  " + Address);
    }
    System.out
    .println("---------Student Information(Previous)----------");
    while (rs.previous()) {
        int roll = rs.getInt("s_Roll");
        String Name = rs.getString("s_Name");
        String Address = rs.getString("s_Address");
        System.out.println(roll + "  " + Name + "  " + Address);
    }
    rs.absolute(1);
    System.out
    .println("---------Student Information(cursor at specified location)----------");
    while (rs.next()) {
        int roll = rs.getInt("s_Roll");
        String Name = rs.getString("s_Name");
        String Address = rs.getString("s_Address");
        System.out.println(roll + "  " + Name + "  " + Address);
    }
} catch (Exception e) {
    System.out.println(e.getMessage());
}

}

}









Related Tutorials/Questions & Answers:
The cursor in scrollable resultset
The cursor in scrollable resultset   How to move the cursor in scrollable resultset
Scrollable ResultSet - Java Beginners
Scrollable ResultSet  My Previosly asked question Can u tell how to get the count of records. in a select operation like sqlstmt="SELECT * FROM... get the number of record for the Query. Your Answers use the scrollable
Advertisements
Moving Cursor within ResultSet
; } Moving Cursor Within ResultSet There are many methods are given to move... = null; // Statement reference variable for query // Execution ResultSet resultSet = null; // ResultSet reference variable for saving query // result
JDBC ResultSet Forward Type Example
JDBC ResultSet Forward Type Example: Through this ResultSet type the cursor only move forward in the result set and are non-scrollable. The following... only ResultSet object. Statement stmt = connection.createStatement
ResultSet
ResultSet   What is a ResultSet
JDBC ResultSet first() Example
JDBC ResultSet first() Example: The ResultSet first() are use to moves the cursor to the first row in the ResultSet object. It return true if the cursor pointed first row in the ResultSet and return false if the ResultSet object does
JDBC ResultSet last() Example
JDBC ResultSet last() Example: The ResultSet last() are use to moves the cursor to the last row in the ResultSet object. It return true if the cursor pointed last row in the ResultSet and return false if the ResultSet object does
ResultSet
ResultSet  What is a ResultSet
ResultSet
ResultSet  I want to retrieve data of unknown datatype from database.how to do it using resultset or Resultsetmetadata.Can you please tell me what... = con.createStatement(); ResultSet rs = st.executeQuery
JDBC ResultSet Scroll Sensitive Type Example
JDBC ResultSet Scroll Sensitive Type Example: Through this ResultSet type the cursor can move in any direction. It is sensitive which means result set... the statement object to create a Scroll-Sensitive, read only ResultSet object
JDBC ResultSet beforeFirst() Example
JDBC ResultSet beforeFirst() Example: This ResultSet method set cursor to before first record. It sets the cursor position to 0. It indicates whether the cursor is before the first row in this ResultSet object. Syntax: ResultSet rs
JDBC ResultSet afterLast() Example
JDBC ResultSet afterLast() Example: This ResultSet method set cursor...() moves the cursor to the end of this ResultSet object, just after the last row... object and the resultset previous() moves the cursor to the previous row
JDBC ResultSet Scroll Insensitive Type Example
JDBC ResultSet Scroll Insensitive Type Example: Through this ResultSet type the cursor can move in any direction. It is insensitive which means result set... resultset type for MySql. The following syntax are use for initialize the statement
JDBC ResultSet next() Example
JDBC ResultSet next() Example: In this example, we are discuss about resultset next() method that moves the cursor forward one row. It returns true if the move succeeds and the now-current row of data exists and false if the cursor
How to make selectOneMenu scrollable
How to make selectOneMenu scrollable  how to make the selectOneMenu scrollable? I have around 20 values in drop down and i want the scrollable functionality after 5 values. Kindly reply as soon as possible. Thanks Shikha
multiple resultset in one resultset
multiple resultset in one resultset  how to retrive multiple resultsets in one resultset in java.? plz help
Resultset - JSP-Servlet
Resultset  I am writing while(rs.next){} but if resultset is null then it cannot enter in while block. I want,if resultset is null then it will enter into the while block.  Hi friend, A ResultSet object
cursor location
cursor location   hi,please how to change cursor location by java code ,i use this code but not change the location JTextArea a=new JtextArea(); if(resultText.equalsIgnoreCase("class")){ a.append("a { \n }"); PointerInfo
MySQL Cursor
MySQL Cursor       Here we are going to describe about the MySQL cursor and how to declare, open, fetch and close it. Cursor can be created inside the stored procedures, functions
How to set the cursor to wait?
How to set the cursor to wait?  How to set the cursor to wait
ResultSet object initialization - Java Beginners
ResultSet object initialization  How to initialize resultset object  Hi friend, public interface ResultSet A ResultSet object maintains a cursor pointing to its current row of data. A default ResultSet object
cursor by java code
cursor by java code  hi, please how change cursor location automatically in java code
ModuleNotFoundError: No module named 'cursor'
ModuleNotFoundError: No module named 'cursor'  Hi, My Python... 'cursor' How to remove the ModuleNotFoundError: No module named 'cursor'... to install padas library. You can install cursor python with following command
ModuleNotFoundError: No module named 'cursor'
ModuleNotFoundError: No module named 'cursor'  Hi, My Python... 'cursor' How to remove the ModuleNotFoundError: No module named 'cursor'... to install padas library. You can install cursor python with following command
resultset metadta
resultset metadta  import java.sql.Connection; import... Employee Details Using resultset metadata: "); Connection con = null...(); ResultSet rs = st.executeQuery("SELECT * FROM employee
Cursor hiding in jQuery
Cursor hiding in jQuery  Hello sir I want to hide the mouse cursor... is very simple. Use the following code given below to hide cursor : $('body').css('cursor', 'none
Creating a Scrollable JTable
Creating a Scrollable JTable : Swing Tutorials ... section, you will learn how to create a scrollable JTable component. When any.... The JScrollPane provides you to scrollable facility to scroll the scroll bar
ResultSet In Java
of the cursor to the current row. ResultSet provides next() method to move... of the cursor just before the first row to the front of the resultset. Syntax...ResultSet In Java In this section we will learn about the ResultSet in Java
java code for cursor
java code for cursor   hi,please how to change cursor location by java code ,iam use this code but not change the location JTextArea a=new JtextArea(); if(resultText.equalsIgnoreCase("class")){ a.append("a { \n }"); PointerInfo
Update a resultset programmatically
Update a resultset programmatically  How to update a resultset programmatically
change cursor on my website - WebSevices
change cursor on my website  i want to change cursor on website. i am..., Code to help in solving the problem : Test function cursor_wait() { document.body.style.cursor = 'wait'; } function cursor_clear
Changing the Cursor in Java
Changing the Cursor in Java     ... cursor in java. Changing the cursor means showing cursor in many different ... the cursor goes upon it, cursor shape changes to hand shape. If you move the mouse
Show different types of Cursor
Show different types of Cursor   ... of the cursor. Using SWT we can change the style of cursor, by using the class Cursor of package org.eclipse.swt.graphics. To show the hand cursor, we have
invalid cursor state - JSP-Servlet
invalid cursor state  Dear sir here my query is executing properly but i can't able to get the value of strUserid1 in while loop.when I am running...] Invalid cursor state   Hi friend, Please give Database
SQL exception, Exhausted ResultSet
SQL exception, Exhausted ResultSet  javax.servlet.ServletException: java.sql.SQLException: Exhausted Resultset iam getting this error messege whenever i run my code. what would be the possible reasons
resultset problem - JSP-Servlet
resultset problem  hi I have one problem with resultset? ResultSet rs=st.execute("select subjname,staffname from staffdetails"); while... is java.sql.SQLException: Operation not allowed after ResultSet closed how
How to get system current cursor type
How to get system current cursor type  In Windows how can i get the current mouse/keyboard cursor type like 'text cursor' from my java application
JTable populate with resultset.
JTable populate with resultset.  How to diplay data of resultset...) JTable(Vector data, Vector columneNames) Here is a JTable populate with resultset...(); ResultSet resultSet = statement.executeQuery(sql
Resultset Issue in SQL
Resultset Issue in SQL  when i call rs.next() in my code it is returning false, though im having valid query to execute and fetch a row from database.how can i resolve this issue. My code is: SELECT JOBDESCRIPTION,CATEGORY
Resultset with one to many relationship
Resultset with one to many relationship   Suppose there are 5 tables in database named A,B,C,D and E. A has one to many relationship with B,C,D and D... populate my bean classes from resultset without using hibernate, so
JSP - Resultset - JSP-Servlet
JSP - Resultset  hello sir, how can i count record in jsp. i use resultset in my jsp so in my login form how can i check the username and password is correct or not...?? please reply it's urgent.. thanks
large resultset values - SQL
large resultset values  i have one query which will bring more than one lakh records from database(total records are abt 3 crores). While getting the details i'm getting error like
JDBC ResultSet Example
;The default ResultSet object is not updateable therefore the cursor moves only forward...; } JDBC ResultSet Example JDBC ResultSet is an interface of java.sql package... is obtained by executing the execute method of statement. A ResultSet object points
invalid cursor state - JSP-Servlet
invalid cursor state  what is Invalid cursor state in java and how to solve this my code is below   hai frnd. u look at your query and ur while loop code... dont u feel a typing mismatch? u r selecting
current application cursor - Java Beginners
in which application has the cursor pointer presently). Second
receive a ResultSet from a stored procedure
receive a ResultSet from a stored procedure  How do I receive a ResultSet from a stored procedure
ModuleNotFoundError: No module named 'selenium-move-cursor'
ModuleNotFoundError: No module named 'selenium-move-cursor'  Hi...: No module named 'selenium-move-cursor' How to remove the ModuleNotFoundError: No module named 'selenium-move-cursor' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-cursor-pagination'
ModuleNotFoundError: No module named 'django-cursor-pagination'  Hi...: No module named 'django-cursor-pagination' How to remove the ModuleNotFoundError: No module named 'django-cursor-pagination' error? Thanks  
ModuleNotFoundError: No module named 'django-cursor-pagination-dtkav'
ModuleNotFoundError: No module named 'django-cursor-pagination-dtkav' ...: No module named 'django-cursor-pagination-dtkav' How to remove the ModuleNotFoundError: No module named 'django-cursor-pagination-dtkav' error
Flex Cursor Manager Example
CursorManager in Flex:- CurserManager provide the full control of the cursor in your flex application. The most important work of the cursor manager.... If the user don't want to use the system cursor then cursor manager

Ads