SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Interface ResultSet
•
•
•
•

public interface ResultSetextends Wrapper
Throws SQLException
{
}
• It is the object of a class that implements java.sql.ResultSet interface
• ResultSet rs=st.executeQuery("select * from students");
• Here executeQuery() returns ResultSet object
ResultSet objects
• ResultSet is a java object in our jdbc application which represents the
records selected from the database table
• Resultset object means it is the object of a class that implements
java.sql.ResultSet interface.
• There are two types of ResultSet interface
• 1. Non Scrollable ResultSet object
• 2. Scrollable ResultSet object
Non Scrollable ResultSet object
• The Resuleset object that allows to access the records only in one
direction (top to bottom), unidirectionally, and squentially is called Non
scrollable ResultSet object.
• The ResultSet object that we have to be worked so far in our all previous
applications is called Non scrollable ResultSet object.
• To create non scrollable result set object
• Statement st=con.createStatement(0;
• ResultSet rs=st.executeQuery(“select * from emp”);
• Resultset object we must go through remaining all the records of ResultSet
object sequentially.’
• When the ResultSet object has more records, this may kill the perfomance
Scrollable ResultSet object
Scrollable ResultSet object
• The ResultSet object that allows to access the record randomly, non
sequentially, bidrectionally and directly is called “Scrollable ResultSet
object”.
• Records of scrollable resultSet objec can be acccessed fastly when
compared to non scrollable resultset object we can go toany record of
scrollable result set object directly without going through its previous
records.
• Based on the parameters that are used to crate statement object, the
statement object takes the decision of creating scrollable or non scrollable
resultSet object.
• Syntax: Statement st=con.createStatement(type,mode);
• ResultSet rs=st.executeQuery(“select * from emp”);
ResultSet types(fields)
• We can set the ResultSet type and concurrency to the Statement objct
while we are creating the Statement object.
• Ex:
1.)createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR
_READ_ONLY);
• 2)
prepareStatement(query, ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CO
NCUR_READ_ONLY);
ResultSet type( fields)
• static int TYPE_FORWARD_ONLY
• The constant indicating the type for
a ResultSet object whose cursor may move
only forward.
ResultSet type( fields)
• static int TYPE_SCROLL_INSENSITIVE
• The constant indicating the type for
a ResultSet object that is scrollable but
generally not sensitive to changes to the data
that underlies the ResultSet.
ResultSet type( fields)
• static int TYPE_SCROLL_SENSITIVE
• The constant indicating the type for
a ResultSet object that is scrollable and
generally sensitive to changes to the data that
underlies the ResultSet.
ResultSet type( fields)
• TYPE_SCROLL_INSENSITIVE
• static final int TYPE_SCROLL_INSENSITIVE
The constant indicating the type for
a ResultSet object that is scrollable but
generally not sensitive to changes to the data
that underlies the ResultSet.
•
• CONCUR_READ_ONLY
• static final int CONCUR_READ_ONLY
The constant indicating the concurrency mode
for a ResultSet object that may NOT be
updated.
• CONCUR_UPDATABLE
• static final int CONCUR_UPDATABLE
The constant indicating the concurrency mode
for a ResultSet object that may be updated.
•
Example prog on ResultSet Type and
ResultSet Concurrency
•

//Example to demonstrate Scrollable ResultSet

•
•
•
•
•

import java.sql.*;
import java.util.*;
import java.io.*;
public class ScrollableRSEx1 {
public static void main(String s[]) throws Exception {

•
•

Driver d= (Driver) ( Class.forName(

•
•
•

Properties p=new Properties ();
p.put("user","root");
p.put("password","admin");

•
•

Connection con=d.connect(

"com.mysql.jdbc.Driver").newInstance());

"jdbc:mysql://localhost:3306/test",p);
•
•

Statement st= con.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);

•
•
•

String query="select * from emp where deptno=10";
•
•

ResultSet rs= st.executeQuery(query);
//Now the cursor of resultset will at beforeFirst & the result set produced is scrollable

•

System.out.println("EmpNotName");

•
•
•
•
•

while (rs.next()) {
System.out.print(rs.getInt(1)+"t");
System.out.println(rs.getString(2));
}//while
//Now the cursor of resultset will at afterLast

•

System.out.println("Reading Data, moving the cursor in backward directionn");

•
•
•
•
•
•
•
•
•
•
•

while (rs.previous()){
System.out.print(rs.getInt(1)+"t");
System.out.println(rs.getString(2));
}//while
con.close();
}//main
}//class
/*
EmpNo
Name
2
uday kumar
Reading Data, moving the cursor in backward direction

•

2

•

*/

uday kumar
getMetaData()
ResultSetMetaData getMetaData() throws SQLException
{
}
• Retrieves the number, types and properties of
this ResultSet object's columns.
• How to call
• ResultSetMetaData rsmd=rs.getMetaData();
rs.getString ( ) • rs.getString ( ) –
• The Result set object call a get String (
),returns you a record set into a formatted
string element.
getDouble()
double getDouble(int columnIndex)
{
}
• Retrieves the value of the designated column
in the current row of this ResultSet object as
a double in the Java programming language.
getString()
• String getString(String columnLabel)
• Retrieves the value of the designated column
in the current row of this ResultSet object as
a String in the Java programming language.
getInt()
• int getInt(String columnLabel)
• Retrieves the value of the designated column
in the current row of this ResultSet object as
an int in the Java programming language.
getDouble()
• Retrieves the value of the designated column
in the current row of this ResultSet object as
a double in the Java programming language.
• double getDouble(String columnLabel)
Note:
• We can send only those java objects over the network that are
Serializable.
• In order to make object as Serializable object, the class of the object must
implement java.io.Serializable interface.
• In order to store data of the object in a file, the object must be serializable
object.
• ResultSet object is not Serializable object, so we can not send this object
over the network directly.
• To overcome this problem, there are two solutions
• 1. Use RowSets in the place of ResultSets.
• 2. copy data of ResultSet object to RowSet

Weitere ähnliche Inhalte

Was ist angesagt?

Microprocessor 80386
Microprocessor 80386Microprocessor 80386
Microprocessor 80386yash sawarkar
 
Unit I-Data Structures_Intoduction.pptx
Unit I-Data Structures_Intoduction.pptxUnit I-Data Structures_Intoduction.pptx
Unit I-Data Structures_Intoduction.pptxDrkhanchanaR
 
NORMALIZATION - BIS 1204: Data and Information Management I
NORMALIZATION - BIS 1204: Data and Information Management I NORMALIZATION - BIS 1204: Data and Information Management I
NORMALIZATION - BIS 1204: Data and Information Management I Mukalele Rogers
 
Cache memory ppt
Cache memory ppt  Cache memory ppt
Cache memory ppt Arpita Naik
 
Project ACRN: SR-IOV implementation
Project ACRN: SR-IOV implementationProject ACRN: SR-IOV implementation
Project ACRN: SR-IOV implementationGeoffroy Van Cutsem
 
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 Data Structures - Lecture 9 [Stack & Queue using Linked List] Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structures - Lecture 9 [Stack & Queue using Linked List]Muhammad Hammad Waseem
 
Limitations of memory system performance
Limitations of memory system performanceLimitations of memory system performance
Limitations of memory system performanceSyed Zaid Irshad
 
Computer Organization Lecture Notes
Computer Organization Lecture NotesComputer Organization Lecture Notes
Computer Organization Lecture NotesFellowBuddy.com
 
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitorssgpraju
 
Computer architecture memory system
Computer architecture memory systemComputer architecture memory system
Computer architecture memory systemMazin Alwaaly
 
Unit 3 graph chapter6
Unit 3  graph chapter6Unit 3  graph chapter6
Unit 3 graph chapter6DrkhanchanaR
 
sistem mikroprosessor 2
sistem mikroprosessor 2sistem mikroprosessor 2
sistem mikroprosessor 2yasir_cesc
 
Directory implementation and allocation methods
Directory implementation and allocation methodsDirectory implementation and allocation methods
Directory implementation and allocation methodssangrampatil81
 
Assembly language (coal)
Assembly language (coal)Assembly language (coal)
Assembly language (coal)Hareem Aslam
 
Advance Database Management Systems -Object Oriented Principles In Database
Advance Database Management Systems -Object Oriented Principles In DatabaseAdvance Database Management Systems -Object Oriented Principles In Database
Advance Database Management Systems -Object Oriented Principles In DatabaseSonali Parab
 

Was ist angesagt? (20)

RAID LEVELS
RAID LEVELSRAID LEVELS
RAID LEVELS
 
Chapter 3 ds
Chapter 3 dsChapter 3 ds
Chapter 3 ds
 
Microprocessor 80386
Microprocessor 80386Microprocessor 80386
Microprocessor 80386
 
16 control unit
16 control unit16 control unit
16 control unit
 
Unit I-Data Structures_Intoduction.pptx
Unit I-Data Structures_Intoduction.pptxUnit I-Data Structures_Intoduction.pptx
Unit I-Data Structures_Intoduction.pptx
 
NORMALIZATION - BIS 1204: Data and Information Management I
NORMALIZATION - BIS 1204: Data and Information Management I NORMALIZATION - BIS 1204: Data and Information Management I
NORMALIZATION - BIS 1204: Data and Information Management I
 
Cache memory ppt
Cache memory ppt  Cache memory ppt
Cache memory ppt
 
Project ACRN: SR-IOV implementation
Project ACRN: SR-IOV implementationProject ACRN: SR-IOV implementation
Project ACRN: SR-IOV implementation
 
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 Data Structures - Lecture 9 [Stack & Queue using Linked List] Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 
Limitations of memory system performance
Limitations of memory system performanceLimitations of memory system performance
Limitations of memory system performance
 
Computer Organization Lecture Notes
Computer Organization Lecture NotesComputer Organization Lecture Notes
Computer Organization Lecture Notes
 
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitors
 
Computer architecture memory system
Computer architecture memory systemComputer architecture memory system
Computer architecture memory system
 
Unit 3 graph chapter6
Unit 3  graph chapter6Unit 3  graph chapter6
Unit 3 graph chapter6
 
sistem mikroprosessor 2
sistem mikroprosessor 2sistem mikroprosessor 2
sistem mikroprosessor 2
 
Directory implementation and allocation methods
Directory implementation and allocation methodsDirectory implementation and allocation methods
Directory implementation and allocation methods
 
Cache memory
Cache  memoryCache  memory
Cache memory
 
Branch prediction
Branch predictionBranch prediction
Branch prediction
 
Assembly language (coal)
Assembly language (coal)Assembly language (coal)
Assembly language (coal)
 
Advance Database Management Systems -Object Oriented Principles In Database
Advance Database Management Systems -Object Oriented Principles In DatabaseAdvance Database Management Systems -Object Oriented Principles In Database
Advance Database Management Systems -Object Oriented Principles In Database
 

Ähnlich wie ResultSet Objects and Types in Java

Scala for Java Developers
Scala for Java DevelopersScala for Java Developers
Scala for Java DevelopersMartin Ockajak
 
standard template library(STL) in C++
standard template library(STL) in C++standard template library(STL) in C++
standard template library(STL) in C++•sreejith •sree
 
Swift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-CSwift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-CAlexis Gallagher
 
13 advanced-swing
13 advanced-swing13 advanced-swing
13 advanced-swingNataraj Dg
 
Cursor & Content Value.pdf
Cursor & Content Value.pdfCursor & Content Value.pdf
Cursor & Content Value.pdfuttamrao7
 
Serializing EMF models with Xtext
Serializing EMF models with XtextSerializing EMF models with Xtext
Serializing EMF models with Xtextmeysholdt
 
Programming in java basics
Programming in java  basicsProgramming in java  basics
Programming in java basicsLovelitJose
 
Jdbc oracle
Jdbc oracleJdbc oracle
Jdbc oracleyazidds2
 
Evan Schultz - Angular Summit - 2016
Evan Schultz - Angular Summit - 2016Evan Schultz - Angular Summit - 2016
Evan Schultz - Angular Summit - 2016Evan Schultz
 
Alternatives of JPA/Hibernate
Alternatives of JPA/HibernateAlternatives of JPA/Hibernate
Alternatives of JPA/HibernateSunghyouk Bae
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almostQuinton Sheppard
 
Intro to JavaScript - Week 4: Object and Array
Intro to JavaScript - Week 4: Object and ArrayIntro to JavaScript - Week 4: Object and Array
Intro to JavaScript - Week 4: Object and ArrayJeongbae Oh
 
JavaScript and the AST
JavaScript and the ASTJavaScript and the AST
JavaScript and the ASTJarrod Overson
 

Ähnlich wie ResultSet Objects and Types in Java (20)

Scala for Java Developers
Scala for Java DevelopersScala for Java Developers
Scala for Java Developers
 
standard template library(STL) in C++
standard template library(STL) in C++standard template library(STL) in C++
standard template library(STL) in C++
 
Swift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-CSwift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-C
 
Unit ii
Unit iiUnit ii
Unit ii
 
Jpa
JpaJpa
Jpa
 
13 advanced-swing
13 advanced-swing13 advanced-swing
13 advanced-swing
 
Cursor & Content Value.pdf
Cursor & Content Value.pdfCursor & Content Value.pdf
Cursor & Content Value.pdf
 
00-review.ppt
00-review.ppt00-review.ppt
00-review.ppt
 
Serializing EMF models with Xtext
Serializing EMF models with XtextSerializing EMF models with Xtext
Serializing EMF models with Xtext
 
Programming in java basics
Programming in java  basicsProgramming in java  basics
Programming in java basics
 
Jdbc oracle
Jdbc oracleJdbc oracle
Jdbc oracle
 
An introduction to scala
An introduction to scalaAn introduction to scala
An introduction to scala
 
Evan Schultz - Angular Summit - 2016
Evan Schultz - Angular Summit - 2016Evan Schultz - Angular Summit - 2016
Evan Schultz - Angular Summit - 2016
 
Alternatives of JPA/Hibernate
Alternatives of JPA/HibernateAlternatives of JPA/Hibernate
Alternatives of JPA/Hibernate
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almost
 
Jdbc
JdbcJdbc
Jdbc
 
Angular2 for Beginners
Angular2 for BeginnersAngular2 for Beginners
Angular2 for Beginners
 
Intro to JavaScript - Week 4: Object and Array
Intro to JavaScript - Week 4: Object and ArrayIntro to JavaScript - Week 4: Object and Array
Intro to JavaScript - Week 4: Object and Array
 
JavaScript and the AST
JavaScript and the ASTJavaScript and the AST
JavaScript and the AST
 
Java
JavaJava
Java
 

Mehr von myrajendra (20)

Fundamentals
FundamentalsFundamentals
Fundamentals
 
Data type
Data typeData type
Data type
 
Hibernate example1
Hibernate example1Hibernate example1
Hibernate example1
 
Jdbc workflow
Jdbc workflowJdbc workflow
Jdbc workflow
 
2 jdbc drivers
2 jdbc drivers2 jdbc drivers
2 jdbc drivers
 
3 jdbc api
3 jdbc api3 jdbc api
3 jdbc api
 
4 jdbc step1
4 jdbc step14 jdbc step1
4 jdbc step1
 
Dao example
Dao exampleDao example
Dao example
 
Sessionex1
Sessionex1Sessionex1
Sessionex1
 
Internal
InternalInternal
Internal
 
3. elements
3. elements3. elements
3. elements
 
2. attributes
2. attributes2. attributes
2. attributes
 
1 introduction to html
1 introduction to html1 introduction to html
1 introduction to html
 
Headings
HeadingsHeadings
Headings
 
Forms
FormsForms
Forms
 
Css
CssCss
Css
 
Views
ViewsViews
Views
 
Views
ViewsViews
Views
 
Views
ViewsViews
Views
 
Starting jdbc
Starting jdbcStarting jdbc
Starting jdbc
 

Kürzlich hochgeladen

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 

Kürzlich hochgeladen (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 

ResultSet Objects and Types in Java

  • 2. • • • • public interface ResultSetextends Wrapper Throws SQLException { }
  • 3. • It is the object of a class that implements java.sql.ResultSet interface • ResultSet rs=st.executeQuery("select * from students"); • Here executeQuery() returns ResultSet object
  • 4.
  • 5. ResultSet objects • ResultSet is a java object in our jdbc application which represents the records selected from the database table • Resultset object means it is the object of a class that implements java.sql.ResultSet interface. • There are two types of ResultSet interface • 1. Non Scrollable ResultSet object • 2. Scrollable ResultSet object
  • 6.
  • 7. Non Scrollable ResultSet object • The Resuleset object that allows to access the records only in one direction (top to bottom), unidirectionally, and squentially is called Non scrollable ResultSet object. • The ResultSet object that we have to be worked so far in our all previous applications is called Non scrollable ResultSet object. • To create non scrollable result set object • Statement st=con.createStatement(0; • ResultSet rs=st.executeQuery(“select * from emp”); • Resultset object we must go through remaining all the records of ResultSet object sequentially.’ • When the ResultSet object has more records, this may kill the perfomance
  • 9. Scrollable ResultSet object • The ResultSet object that allows to access the record randomly, non sequentially, bidrectionally and directly is called “Scrollable ResultSet object”. • Records of scrollable resultSet objec can be acccessed fastly when compared to non scrollable resultset object we can go toany record of scrollable result set object directly without going through its previous records. • Based on the parameters that are used to crate statement object, the statement object takes the decision of creating scrollable or non scrollable resultSet object. • Syntax: Statement st=con.createStatement(type,mode); • ResultSet rs=st.executeQuery(“select * from emp”);
  • 10. ResultSet types(fields) • We can set the ResultSet type and concurrency to the Statement objct while we are creating the Statement object. • Ex: 1.)createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR _READ_ONLY); • 2) prepareStatement(query, ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CO NCUR_READ_ONLY);
  • 11. ResultSet type( fields) • static int TYPE_FORWARD_ONLY • The constant indicating the type for a ResultSet object whose cursor may move only forward.
  • 12. ResultSet type( fields) • static int TYPE_SCROLL_INSENSITIVE • The constant indicating the type for a ResultSet object that is scrollable but generally not sensitive to changes to the data that underlies the ResultSet.
  • 13. ResultSet type( fields) • static int TYPE_SCROLL_SENSITIVE • The constant indicating the type for a ResultSet object that is scrollable and generally sensitive to changes to the data that underlies the ResultSet.
  • 14. ResultSet type( fields) • TYPE_SCROLL_INSENSITIVE • static final int TYPE_SCROLL_INSENSITIVE The constant indicating the type for a ResultSet object that is scrollable but generally not sensitive to changes to the data that underlies the ResultSet. •
  • 15. • CONCUR_READ_ONLY • static final int CONCUR_READ_ONLY The constant indicating the concurrency mode for a ResultSet object that may NOT be updated.
  • 16. • CONCUR_UPDATABLE • static final int CONCUR_UPDATABLE The constant indicating the concurrency mode for a ResultSet object that may be updated. •
  • 17. Example prog on ResultSet Type and ResultSet Concurrency • //Example to demonstrate Scrollable ResultSet • • • • • import java.sql.*; import java.util.*; import java.io.*; public class ScrollableRSEx1 { public static void main(String s[]) throws Exception { • • Driver d= (Driver) ( Class.forName( • • • Properties p=new Properties (); p.put("user","root"); p.put("password","admin"); • • Connection con=d.connect( "com.mysql.jdbc.Driver").newInstance()); "jdbc:mysql://localhost:3306/test",p); • • Statement st= con.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); • • • String query="select * from emp where deptno=10";
  • 18. • • ResultSet rs= st.executeQuery(query); //Now the cursor of resultset will at beforeFirst & the result set produced is scrollable • System.out.println("EmpNotName"); • • • • • while (rs.next()) { System.out.print(rs.getInt(1)+"t"); System.out.println(rs.getString(2)); }//while //Now the cursor of resultset will at afterLast • System.out.println("Reading Data, moving the cursor in backward directionn"); • • • • • • • • • • • while (rs.previous()){ System.out.print(rs.getInt(1)+"t"); System.out.println(rs.getString(2)); }//while con.close(); }//main }//class /* EmpNo Name 2 uday kumar Reading Data, moving the cursor in backward direction • 2 • */ uday kumar
  • 19. getMetaData() ResultSetMetaData getMetaData() throws SQLException { } • Retrieves the number, types and properties of this ResultSet object's columns. • How to call • ResultSetMetaData rsmd=rs.getMetaData();
  • 20. rs.getString ( ) • rs.getString ( ) – • The Result set object call a get String ( ),returns you a record set into a formatted string element.
  • 21. getDouble() double getDouble(int columnIndex) { } • Retrieves the value of the designated column in the current row of this ResultSet object as a double in the Java programming language.
  • 22. getString() • String getString(String columnLabel) • Retrieves the value of the designated column in the current row of this ResultSet object as a String in the Java programming language.
  • 23. getInt() • int getInt(String columnLabel) • Retrieves the value of the designated column in the current row of this ResultSet object as an int in the Java programming language.
  • 24. getDouble() • Retrieves the value of the designated column in the current row of this ResultSet object as a double in the Java programming language. • double getDouble(String columnLabel)
  • 25. Note: • We can send only those java objects over the network that are Serializable. • In order to make object as Serializable object, the class of the object must implement java.io.Serializable interface. • In order to store data of the object in a file, the object must be serializable object. • ResultSet object is not Serializable object, so we can not send this object over the network directly. • To overcome this problem, there are two solutions • 1. Use RowSets in the place of ResultSets. • 2. copy data of ResultSet object to RowSet