SlideShare a Scribd company logo
Prepared Statement Interface
•It extends the statement interface.
•Multiple executions of a SQL statement pre-
compiled and stored in a PreparedStatement
object.
•Methods
•executeQuery() – execute SQL statements
•executeUpdate() – execute SQL UPDATE, DELETE
or INSERT statements. DDL statements can also be
executed if the SQL statements does not return
values.
ResultSet interface
•It stored, accessed data from the database.
•It watches single row of a data at a time. The row
of data is called current row.
•Methods
•void close() – release a resultset database
resource and JDBC resources.
•void getString() – gets the value of a column in the
current row.
•next() – it is used to retrieve the next row values.
ResultSetMetaData interface
•It is returned by getMetaData() constructor
provides access to information which indicates the
number, type and properties of resultset columns
•Methods
•getColumnCount() – returns the number of
columns in the resultset.
•String getColumnName(int) – returns the name of
the column.
•getTableName() – returns the name of a table
Connecting to Remote Database
•Steps to connect remote database
1. Loading an appropriate database server
2.Locating a DBMS on the harddisk
3. Establishing a connection
4. Creating and firing SQL queries against the database
5. Creating a RecordSet object
Connecting to Remote Database
•Choosing an appropriate driver
•Driver is required to allow the JDBC API to manage the
connection.
•Java program code is used to force a particular
database driver to be loaded.
•Eg.:JDBC-ODBC bridge driver:
•Class.forName(“sun:jdbc.odbc.JdbcOdbcDriver”);
Connecting to remote database
•getConnection() method of the DriverManager is
used to request a Connection Object.
•A variable called url is used to hold the binding
between the jdbc:odbc bridge and the name of the
DSN.
•E.g.:
•String url=“jdbc:odbc:datasource”;
•Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
•Connection conn=Driver.getConnection(url);
Connecting to Remote Database
•Performing database queries and updates
•It provides various techniques of performing database
queries and updates.
•The SQL statement is created using createStatement()
method.
•Syntax: Statement createStatement();
•E.g.:
•Statement st=conn.createStatement();
Navigating Multiple Rows retrieved from database
•It can be retrieved by resultset query.
•Extraction of values from the current row is
possible in two ways
•Accessing columns of the current row by index number
•Accessing columns of the current row by name
Navigating Multiple Rows retrieved from database
•Accessing columns by the column indexes
•It is used to fetch column data of the current row by using the column
index
•Methods
•String getString(int columnindex)
•Boolean getBoolean(int columnindex)
•Byte getByte(int columnindex)
•Short getShort(int columnindex)
•Int getInt(int columnindex)
•Long getLong(int columnindex)
•Float getFloat(int columnindex)
•Double getDouble(int columnindex)
•rs.getString(1);
•rs.getLong(3);
Navigating Multiple Rows retrieved from database
•Accessing columns by the column names
•It is more convenient to use as a means of access to columns.
•Methods
•String getString(int columnname)
•Boolean getBoolean(int columnname)
•Byte getByte(int columnname)
•Short getShort(int columnname)
•Int getInt(int columnname)
•Long getLong(int columnname)
•Float getFloat(int columnname)
•Double getDouble(int columnname)
•rs.getString(“name”);
•rs.getLong(“salary”);
Data manipulation
•Inserting, Deleting and Updating records in an access table
using Java code.
•Insert Record – adds a new value to the database.
•E.g.: Insert into tablename values(column values);
•Update Record – This parts update the records in the
database.
•E.g.: Update tablename set columnname1=value1,
columnname2=value2…
•Delete Record – It deletes the records in the database.
•E.g.: Delete from tablename where columnname=value;
•Retrieve record – select * from tablename where
columnname=value or select * from tablename;
Data navigation
•The portion of the code deals with navigation through
the records.
•The records from the ResultSet are stored in the
vector and the navigation of the records are done
through the vector.
•Methods
•First() – move to the first record
•Next() – move to the next record
•Last() – move to the last record
•Previous() – move to the previous record
•E.g.: rs.first(); rs.next(); rs.last(); rs.previous();

More Related Content

What's hot

Introduction to data structure by anil dutt
Introduction to data structure by anil duttIntroduction to data structure by anil dutt
Introduction to data structure by anil dutt
Anil Dutt
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its types
Navtar Sidhu Brar
 
R Get Started I
R Get Started IR Get Started I
R Get Started I
Sankhya_Analytics
 
LectureNotes-03-DSA
LectureNotes-03-DSALectureNotes-03-DSA
LectureNotes-03-DSA
Haitham El-Ghareeb
 
Data structure lecture 1
Data structure lecture 1Data structure lecture 1
Data structure lecture 1
Kumar
 
Introduction to data structure
Introduction to data structure Introduction to data structure
Introduction to data structure
NUPOORAWSARMOL
 
Ds lists
Ds listsDs lists
Ds lists
Dzinh Tuong
 
Query hierarchical data the easy way, with CTEs
Query hierarchical data the easy way, with CTEsQuery hierarchical data the easy way, with CTEs
Query hierarchical data the easy way, with CTEs
MariaDB plc
 
R Get Started II
R Get Started IIR Get Started II
R Get Started II
Sankhya_Analytics
 
Data structures
Data structuresData structures
Data structures
Manaswi Sharma
 
Data structure and algorithm All in One
Data structure and algorithm All in OneData structure and algorithm All in One
Data structure and algorithm All in One
jehan1987
 
2CPP16 - STL
2CPP16 - STL2CPP16 - STL
2CPP16 - STL
Michael Heron
 
264finalppt (1)
264finalppt (1)264finalppt (1)
264finalppt (1)
Mahima Verma
 
Data structure
Data structureData structure
Data structure
Muhammad Farhan
 
Wrokflow programming and provenance query model
Wrokflow programming and provenance query model  Wrokflow programming and provenance query model
Wrokflow programming and provenance query model
Rayhan Ferdous
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
Poojith Chowdhary
 
Data structure , stack , queue
Data structure , stack , queueData structure , stack , queue
Data structure , stack , queue
Rajkiran Nadar
 
XML Data Types in the Real World
XML Data Types in the Real WorldXML Data Types in the Real World
XML Data Types in the Real World
Steve Hughes
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
blessyboban92
 
Data structures & algorithms lecture 3
Data structures & algorithms lecture 3Data structures & algorithms lecture 3
Data structures & algorithms lecture 3
Poojith Chowdhary
 

What's hot (20)

Introduction to data structure by anil dutt
Introduction to data structure by anil duttIntroduction to data structure by anil dutt
Introduction to data structure by anil dutt
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its types
 
R Get Started I
R Get Started IR Get Started I
R Get Started I
 
LectureNotes-03-DSA
LectureNotes-03-DSALectureNotes-03-DSA
LectureNotes-03-DSA
 
Data structure lecture 1
Data structure lecture 1Data structure lecture 1
Data structure lecture 1
 
Introduction to data structure
Introduction to data structure Introduction to data structure
Introduction to data structure
 
Ds lists
Ds listsDs lists
Ds lists
 
Query hierarchical data the easy way, with CTEs
Query hierarchical data the easy way, with CTEsQuery hierarchical data the easy way, with CTEs
Query hierarchical data the easy way, with CTEs
 
R Get Started II
R Get Started IIR Get Started II
R Get Started II
 
Data structures
Data structuresData structures
Data structures
 
Data structure and algorithm All in One
Data structure and algorithm All in OneData structure and algorithm All in One
Data structure and algorithm All in One
 
2CPP16 - STL
2CPP16 - STL2CPP16 - STL
2CPP16 - STL
 
264finalppt (1)
264finalppt (1)264finalppt (1)
264finalppt (1)
 
Data structure
Data structureData structure
Data structure
 
Wrokflow programming and provenance query model
Wrokflow programming and provenance query model  Wrokflow programming and provenance query model
Wrokflow programming and provenance query model
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Data structure , stack , queue
Data structure , stack , queueData structure , stack , queue
Data structure , stack , queue
 
XML Data Types in the Real World
XML Data Types in the Real WorldXML Data Types in the Real World
XML Data Types in the Real World
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
 
Data structures & algorithms lecture 3
Data structures & algorithms lecture 3Data structures & algorithms lecture 3
Data structures & algorithms lecture 3
 

Similar to Jdbc

Java 1-contd
Java 1-contdJava 1-contd
Java 1-contd
Mukesh Tekwani
 
Cursor & Content Value.pdf
Cursor & Content Value.pdfCursor & Content Value.pdf
Cursor & Content Value.pdf
uttamrao7
 
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...
TAISEEREISA
 
Sql lite android
Sql lite androidSql lite android
Sql lite android
Dushyant Nasit
 
Java OOP Programming language (Part 8) - Java Database JDBC
Java OOP Programming language (Part 8) - Java Database JDBCJava OOP Programming language (Part 8) - Java Database JDBC
Java OOP Programming language (Part 8) - Java Database JDBC
OUM SAOKOSAL
 
OOP Lecture 18-DB Connectivity-Part2.pptx
OOP Lecture 18-DB Connectivity-Part2.pptxOOP Lecture 18-DB Connectivity-Part2.pptx
OOP Lecture 18-DB Connectivity-Part2.pptx
Tanzila Kehkashan
 
Jdbc presentation
Jdbc presentationJdbc presentation
Jdbc presentation
nrjoshiee
 
Jdbc oracle
Jdbc oracleJdbc oracle
Jdbc oracle
yazidds2
 
Shshsjsjsjs-4 - Copdjsjjsjsjsjakakakaaky.pptx
Shshsjsjsjs-4 - Copdjsjjsjsjsjakakakaaky.pptxShshsjsjsjs-4 - Copdjsjjsjsjsjakakakaaky.pptx
Shshsjsjsjs-4 - Copdjsjjsjsjsjakakakaaky.pptx
086ChintanPatel1
 
Android Database
Android DatabaseAndroid Database
Android Database
Dr Karthikeyan Periasamy
 
Collections in Java
Collections in JavaCollections in Java
Collections in Java
Khasim Cise
 
Sql Connection and data table and data set and sample program in C# ....
Sql Connection and data table and data set and sample program in C# ....Sql Connection and data table and data set and sample program in C# ....
Sql Connection and data table and data set and sample program in C# ....
Hari Haran
 
Collections
CollectionsCollections
Collections
Rajkattamuri
 
Collections
CollectionsCollections
Collections
Manav Prasad
 
Collections Framework Beginners Guide 2
Collections Framework Beginners Guide 2Collections Framework Beginners Guide 2
Collections Framework Beginners Guide 2
Kenji HASUNUMA
 
Collections Framework Begineers guide 2
Collections Framework Begineers guide 2Collections Framework Begineers guide 2
Collections Framework Begineers guide 2
Kenji HASUNUMA
 
Jsp project module
Jsp project moduleJsp project module
Interface result set
Interface result setInterface result set
Interface result set
myrajendra
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
Sourabh Sahu
 
MWLUG Session- AD112 - Take a Trip Into the Forest - A Java Primer on Maps, ...
MWLUG Session-  AD112 - Take a Trip Into the Forest - A Java Primer on Maps, ...MWLUG Session-  AD112 - Take a Trip Into the Forest - A Java Primer on Maps, ...
MWLUG Session- AD112 - Take a Trip Into the Forest - A Java Primer on Maps, ...
Howard Greenberg
 

Similar to Jdbc (20)

Java 1-contd
Java 1-contdJava 1-contd
Java 1-contd
 
Cursor & Content Value.pdf
Cursor & Content Value.pdfCursor & Content Value.pdf
Cursor & Content Value.pdf
 
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...
 
Sql lite android
Sql lite androidSql lite android
Sql lite android
 
Java OOP Programming language (Part 8) - Java Database JDBC
Java OOP Programming language (Part 8) - Java Database JDBCJava OOP Programming language (Part 8) - Java Database JDBC
Java OOP Programming language (Part 8) - Java Database JDBC
 
OOP Lecture 18-DB Connectivity-Part2.pptx
OOP Lecture 18-DB Connectivity-Part2.pptxOOP Lecture 18-DB Connectivity-Part2.pptx
OOP Lecture 18-DB Connectivity-Part2.pptx
 
Jdbc presentation
Jdbc presentationJdbc presentation
Jdbc presentation
 
Jdbc oracle
Jdbc oracleJdbc oracle
Jdbc oracle
 
Shshsjsjsjs-4 - Copdjsjjsjsjsjakakakaaky.pptx
Shshsjsjsjs-4 - Copdjsjjsjsjsjakakakaaky.pptxShshsjsjsjs-4 - Copdjsjjsjsjsjakakakaaky.pptx
Shshsjsjsjs-4 - Copdjsjjsjsjsjakakakaaky.pptx
 
Android Database
Android DatabaseAndroid Database
Android Database
 
Collections in Java
Collections in JavaCollections in Java
Collections in Java
 
Sql Connection and data table and data set and sample program in C# ....
Sql Connection and data table and data set and sample program in C# ....Sql Connection and data table and data set and sample program in C# ....
Sql Connection and data table and data set and sample program in C# ....
 
Collections
CollectionsCollections
Collections
 
Collections
CollectionsCollections
Collections
 
Collections Framework Beginners Guide 2
Collections Framework Beginners Guide 2Collections Framework Beginners Guide 2
Collections Framework Beginners Guide 2
 
Collections Framework Begineers guide 2
Collections Framework Begineers guide 2Collections Framework Begineers guide 2
Collections Framework Begineers guide 2
 
Jsp project module
Jsp project moduleJsp project module
Jsp project module
 
Interface result set
Interface result setInterface result set
Interface result set
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
 
MWLUG Session- AD112 - Take a Trip Into the Forest - A Java Primer on Maps, ...
MWLUG Session-  AD112 - Take a Trip Into the Forest - A Java Primer on Maps, ...MWLUG Session-  AD112 - Take a Trip Into the Forest - A Java Primer on Maps, ...
MWLUG Session- AD112 - Take a Trip Into the Forest - A Java Primer on Maps, ...
 

Recently uploaded

Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
ssuser13ffe4
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
imrankhan141184
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
MysoreMuleSoftMeetup
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
S. Raj Kumar
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
ZK on Polkadot zero knowledge proofs - sub0.pptx
ZK on Polkadot zero knowledge proofs - sub0.pptxZK on Polkadot zero knowledge proofs - sub0.pptx
ZK on Polkadot zero knowledge proofs - sub0.pptx
dot55audits
 
Solutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptxSolutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptx
spdendr
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 

Recently uploaded (20)

Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
ZK on Polkadot zero knowledge proofs - sub0.pptx
ZK on Polkadot zero knowledge proofs - sub0.pptxZK on Polkadot zero knowledge proofs - sub0.pptx
ZK on Polkadot zero knowledge proofs - sub0.pptx
 
Solutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptxSolutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptx
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 

Jdbc

  • 1. Prepared Statement Interface •It extends the statement interface. •Multiple executions of a SQL statement pre- compiled and stored in a PreparedStatement object. •Methods •executeQuery() – execute SQL statements •executeUpdate() – execute SQL UPDATE, DELETE or INSERT statements. DDL statements can also be executed if the SQL statements does not return values.
  • 2. ResultSet interface •It stored, accessed data from the database. •It watches single row of a data at a time. The row of data is called current row. •Methods •void close() – release a resultset database resource and JDBC resources. •void getString() – gets the value of a column in the current row. •next() – it is used to retrieve the next row values.
  • 3. ResultSetMetaData interface •It is returned by getMetaData() constructor provides access to information which indicates the number, type and properties of resultset columns •Methods •getColumnCount() – returns the number of columns in the resultset. •String getColumnName(int) – returns the name of the column. •getTableName() – returns the name of a table
  • 4. Connecting to Remote Database •Steps to connect remote database 1. Loading an appropriate database server 2.Locating a DBMS on the harddisk 3. Establishing a connection 4. Creating and firing SQL queries against the database 5. Creating a RecordSet object
  • 5. Connecting to Remote Database •Choosing an appropriate driver •Driver is required to allow the JDBC API to manage the connection. •Java program code is used to force a particular database driver to be loaded. •Eg.:JDBC-ODBC bridge driver: •Class.forName(“sun:jdbc.odbc.JdbcOdbcDriver”);
  • 6. Connecting to remote database •getConnection() method of the DriverManager is used to request a Connection Object. •A variable called url is used to hold the binding between the jdbc:odbc bridge and the name of the DSN. •E.g.: •String url=“jdbc:odbc:datasource”; •Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”); •Connection conn=Driver.getConnection(url);
  • 7. Connecting to Remote Database •Performing database queries and updates •It provides various techniques of performing database queries and updates. •The SQL statement is created using createStatement() method. •Syntax: Statement createStatement(); •E.g.: •Statement st=conn.createStatement();
  • 8. Navigating Multiple Rows retrieved from database •It can be retrieved by resultset query. •Extraction of values from the current row is possible in two ways •Accessing columns of the current row by index number •Accessing columns of the current row by name
  • 9. Navigating Multiple Rows retrieved from database •Accessing columns by the column indexes •It is used to fetch column data of the current row by using the column index •Methods •String getString(int columnindex) •Boolean getBoolean(int columnindex) •Byte getByte(int columnindex) •Short getShort(int columnindex) •Int getInt(int columnindex) •Long getLong(int columnindex) •Float getFloat(int columnindex) •Double getDouble(int columnindex) •rs.getString(1); •rs.getLong(3);
  • 10. Navigating Multiple Rows retrieved from database •Accessing columns by the column names •It is more convenient to use as a means of access to columns. •Methods •String getString(int columnname) •Boolean getBoolean(int columnname) •Byte getByte(int columnname) •Short getShort(int columnname) •Int getInt(int columnname) •Long getLong(int columnname) •Float getFloat(int columnname) •Double getDouble(int columnname) •rs.getString(“name”); •rs.getLong(“salary”);
  • 11. Data manipulation •Inserting, Deleting and Updating records in an access table using Java code. •Insert Record – adds a new value to the database. •E.g.: Insert into tablename values(column values); •Update Record – This parts update the records in the database. •E.g.: Update tablename set columnname1=value1, columnname2=value2… •Delete Record – It deletes the records in the database. •E.g.: Delete from tablename where columnname=value; •Retrieve record – select * from tablename where columnname=value or select * from tablename;
  • 12. Data navigation •The portion of the code deals with navigation through the records. •The records from the ResultSet are stored in the vector and the navigation of the records are done through the vector. •Methods •First() – move to the first record •Next() – move to the next record •Last() – move to the last record •Previous() – move to the previous record •E.g.: rs.first(); rs.next(); rs.last(); rs.previous();