Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC The cursor in scrollable resultset
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Clark
The cursor in scrollable resultset
1 Answer(s)      4 years and 2 months ago
Posted in : JDBC


How to move the cursor in scrollable resultset ?


Advertisement
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
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  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
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
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
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
multiple resultset in one resultset
multiple resultset in one resultset  how to retrive multiple resultsets in one resultset in java.? plz help
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
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
How to set the cursor to wait?
How to set the cursor to wait?  How to set the cursor to wait
cursor by java code
cursor by java code  hi, please how change cursor location automatically in java code
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
Cursor hiding in jQuery
Cursor hiding in jQuery  Hello sir I want to hide the mouse cursor in entire web page. I heard from one of my friend that it is possible using.... Use the following code given below to hide cursor : $('body').css('cursor
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
resultset metadta
resultset metadta  import java.sql.Connection; import... Employee Details Using resultset metadata: "); Connection con = null...(); ResultSet rs = st.executeQuery("SELECT * FROM employee
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
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
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
ResultSet In Java
of the cursor to the current row. ResultSet provides next() method to move...ResultSet In Java In this section we will learn about the ResultSet in Java... that are mostly used in to get the value. ResultSet contains the data of a table after
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
Update a resultset programmatically
Update a resultset programmatically  How to update a resultset programmatically
 

 

 

DMCA.com