SlideShare une entreprise Scribd logo
1  sur  18
ALEX JOSE
KV PATTOM SHIFT-I
CONCEPT MAPPING
 DriverManager Class : It is the class used to load
JDBC Driver needed to access particular database.
 Connection class : It manages the connection and
communication to the database.
 Statement Class: It contains the string that are
submitted to the database for execution. And it will
execute the SQL statement.
 ResultSet Class : If the statement class contains select
statement, then during the execution it will return
selected rows from the database are assigned to
ResultSet and it contains the methods to move
through the rows and get the values.
 Step1. import packages required for Database
Programming.
 Step2. Register the JDBC Driver.
 Open a connection.
 Execute a Query.
 Extract data from the ResultSet.
 Cleanup the environment.
DESIGN THE INTERFACE AS PER REQUIREMENT
 1. Import the packages required for Database
Programming
 import java.sql.*;
 2. Register the JDBC Driver with Java Program.
 Class.forName(“java.sql.DriverManager");
 3. Open the connection.
 This requires using the
DriverManager.getConnection() method to create
a connection object, which represents the
physical connection with the database. To
connect to the database, we need complete URL
to the database with userid and password of
MySQL.
 4. Execute a query.
 We need to create an object of type Statement or
PreparedStatement for building and submitting
an SQL statement to the database using the
createStatement() function of Connection class.
 in the Statement class executeQuery() method is
needed to execute select statement in SQL and
executeUpdate() method is to execute DML
statements.
 if the SQL command is Select statement we need
a class called ResultSet to store and process the
records.
 The Result set refers to a logical set of records
that are fetched from the database by executing
a query and made available to the application
program.
 next()
 moves the cursor forward one
 first()
 to move to the firts row.
 last()
 move the cursor to the lat lasr row.
 relative(int rows)
 moves the cursor relative to the current position.
 absolute(int rno)
 position the cursor on the rno th rows in the
ResultSet.
 getRow()
 to get the current cursor position.
Extract data from ResultSet
 ResultSet class has several methods to get
the values from the columns from the rows
pointed by the cursor.
 getInt("FieldName");
 getString("FieldName");
getString(fieldNumber);
 getFloat("FieldName");
 getDate("FieldName");
 getLong("FieldName");.
DISPLAYING DATA IN TABLES
 DefaultTableModel dtm=(javax.swing.table.DefaultTableModel)studenttab.getModel();
 int rows=dtm.getRowCount();
 if(rows>0)
 {
 for(int i=0;i<rows;i++)
 {
 dtm.removeRow(0);
 }
 }
 try
 {
 Class.forName("java.sql.DriverManager");
 Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/mydbll“,"root","");
 Statement stmt=con.createStatement();
 String str="select * from student";
 ResultSet rs=stmt.executeQuery(str);
 while(rs.next())
 {
 int sid=rs.getInt("stdid");
 String sname= rs.getString("stdname");
int mark= rs.getInt(“mark");
 Object obj[]={sid,sname,mark};
 dtm.addRow(obj);

 }
 }
 catch(Exception e)
 {
 System.out.println(e);
 }
 Executing the select statement having criteria.
 String str=”select * from student where stdid=”+
t1.getText;
 String str=”select * from student where stsname=’ ” +
tname.getText() +” ’ ”;

 To Execute DML commands
 Int sid=Integer.parseInt(t1.getText());
 String sname= tname.getText();
 Int mark=Integer.parseInt(tmark.getText());
 String str=”insert into student values(“+ sid+” , ’ “ +
sname +” ’ , “+ mark +”)”;
 Stmt.executeUpdate(str);
 String str=”delete * from student where stdid=” +
t1.getText() +”)”;
 Stmt.executeUpdate(str);

 String str=”update student set mark =mark+5 where
stdname=’ ” + tname.getText() +” ’ )”;
 Stmt.executeUpdate(str);
Java Databse Connectvity- Alex Jose

Contenu connexe

Tendances (20)

Intake 38 10
Intake 38 10Intake 38 10
Intake 38 10
 
Weka
WekaWeka
Weka
 
1 list datastructures
1 list datastructures1 list datastructures
1 list datastructures
 
MATLAB Bioinformatics tool box
MATLAB Bioinformatics tool boxMATLAB Bioinformatics tool box
MATLAB Bioinformatics tool box
 
Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structure
 
3 searching algorithms in Java
3 searching algorithms in Java3 searching algorithms in Java
3 searching algorithms in Java
 
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
 
Collections framework in java
Collections framework in javaCollections framework in java
Collections framework in java
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its types
 
Java collections
Java collectionsJava collections
Java collections
 
2 b queues
2 b queues2 b queues
2 b queues
 
Matlab bioinformatics presentation
Matlab bioinformatics presentationMatlab bioinformatics presentation
Matlab bioinformatics presentation
 
Data structures
Data structuresData structures
Data structures
 
Java - Collections
Java - CollectionsJava - Collections
Java - Collections
 
2 a stacks
2 a stacks2 a stacks
2 a stacks
 
Data structures project
Data structures projectData structures project
Data structures project
 
Java Stack Data Structure.pptx
Java Stack Data Structure.pptxJava Stack Data Structure.pptx
Java Stack Data Structure.pptx
 
Advanced core java
Advanced core javaAdvanced core java
Advanced core java
 
ICOM4015_CIIC4010 Exam Review #2
ICOM4015_CIIC4010 Exam Review #2ICOM4015_CIIC4010 Exam Review #2
ICOM4015_CIIC4010 Exam Review #2
 
Collections in Java
Collections in JavaCollections in Java
Collections in Java
 

En vedette

Find us on Facebook - Facebook jako narzędzie komunikacji marki
Find us on Facebook - Facebook jako narzędzie komunikacji markiFind us on Facebook - Facebook jako narzędzie komunikacji marki
Find us on Facebook - Facebook jako narzędzie komunikacji markiEsplanada
 
Netherlands(Report)
Netherlands(Report)Netherlands(Report)
Netherlands(Report)Terry Kao
 
Presentation3
Presentation3Presentation3
Presentation3fm00001
 
reccebladet-13rätta
reccebladet-13rättareccebladet-13rätta
reccebladet-13rättaAlexander K
 
10 key Story Questions
10 key Story Questions10 key Story Questions
10 key Story Questionsdbotsford
 
Лечебное голодание. Презентация к лекции Лилии Горелой
Лечебное голодание. Презентация к лекции Лилии ГорелойЛечебное голодание. Презентация к лекции Лилии Горелой
Лечебное голодание. Презентация к лекции Лилии ГорелойМихаил Букреев
 
CROATIA - a lifetime experience with Sailing Place _)
CROATIA - a lifetime experience with Sailing Place _)CROATIA - a lifetime experience with Sailing Place _)
CROATIA - a lifetime experience with Sailing Place _)Andelo Zeravica
 

En vedette (11)

Find us on Facebook - Facebook jako narzędzie komunikacji marki
Find us on Facebook - Facebook jako narzędzie komunikacji markiFind us on Facebook - Facebook jako narzędzie komunikacji marki
Find us on Facebook - Facebook jako narzędzie komunikacji marki
 
Piquete Antibala
Piquete AntibalaPiquete Antibala
Piquete Antibala
 
Netherlands(Report)
Netherlands(Report)Netherlands(Report)
Netherlands(Report)
 
Presentation3
Presentation3Presentation3
Presentation3
 
reccebladet-13rätta
reccebladet-13rättareccebladet-13rätta
reccebladet-13rätta
 
10 key Story Questions
10 key Story Questions10 key Story Questions
10 key Story Questions
 
Plantilla de diseño
Plantilla de diseñoPlantilla de diseño
Plantilla de diseño
 
Enfasis en-los-procesos
Enfasis en-los-procesosEnfasis en-los-procesos
Enfasis en-los-procesos
 
Лечебное голодание. Презентация к лекции Лилии Горелой
Лечебное голодание. Презентация к лекции Лилии ГорелойЛечебное голодание. Презентация к лекции Лилии Горелой
Лечебное голодание. Презентация к лекции Лилии Горелой
 
CROATIA - a lifetime experience with Sailing Place _)
CROATIA - a lifetime experience with Sailing Place _)CROATIA - a lifetime experience with Sailing Place _)
CROATIA - a lifetime experience with Sailing Place _)
 
Ecological Agriculture
Ecological AgricultureEcological Agriculture
Ecological Agriculture
 

Similaire à Java Databse Connectvity- Alex Jose

Scrollable Updatable
Scrollable UpdatableScrollable Updatable
Scrollable Updatableleminhvuong
 
Scrollable Updatable
Scrollable UpdatableScrollable Updatable
Scrollable Updatablephanleson
 
Executing Sql Commands
Executing Sql CommandsExecuting Sql Commands
Executing Sql Commandsphanleson
 
Executing Sql Commands
Executing Sql CommandsExecuting Sql Commands
Executing Sql Commandsleminhvuong
 
Introduction to JDBC and database access in web applications
Introduction to JDBC and database access in web applicationsIntroduction to JDBC and database access in web applications
Introduction to JDBC and database access in web applicationsFulvio Corno
 
JDBC JAVA DATABASE CONNECTIVITY AND JAVA
JDBC JAVA DATABASE CONNECTIVITY AND JAVAJDBC JAVA DATABASE CONNECTIVITY AND JAVA
JDBC JAVA DATABASE CONNECTIVITY AND JAVAAdarshSrungarapu
 
30 5 Database Jdbc
30 5 Database Jdbc30 5 Database Jdbc
30 5 Database Jdbcphanleson
 
jdbc_presentation.ppt
jdbc_presentation.pptjdbc_presentation.ppt
jdbc_presentation.pptDrMeenakshiS
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivityAtul Saurabh
 

Similaire à Java Databse Connectvity- Alex Jose (20)

Java 1-contd
Java 1-contdJava 1-contd
Java 1-contd
 
Scrollable Updatable
Scrollable UpdatableScrollable Updatable
Scrollable Updatable
 
Scrollable Updatable
Scrollable UpdatableScrollable Updatable
Scrollable Updatable
 
Executing Sql Commands
Executing Sql CommandsExecuting Sql Commands
Executing Sql Commands
 
Executing Sql Commands
Executing Sql CommandsExecuting Sql Commands
Executing Sql Commands
 
Jdbc[1]
Jdbc[1]Jdbc[1]
Jdbc[1]
 
JDBC programming
JDBC programmingJDBC programming
JDBC programming
 
Introduction to JDBC and database access in web applications
Introduction to JDBC and database access in web applicationsIntroduction to JDBC and database access in web applications
Introduction to JDBC and database access in web applications
 
Jdbc api
Jdbc apiJdbc api
Jdbc api
 
JDBC JAVA DATABASE CONNECTIVITY AND JAVA
JDBC JAVA DATABASE CONNECTIVITY AND JAVAJDBC JAVA DATABASE CONNECTIVITY AND JAVA
JDBC JAVA DATABASE CONNECTIVITY AND JAVA
 
Jdbc 1
Jdbc 1Jdbc 1
Jdbc 1
 
JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
 
30 5 Database Jdbc
30 5 Database Jdbc30 5 Database Jdbc
30 5 Database Jdbc
 
spring-tutorial
spring-tutorialspring-tutorial
spring-tutorial
 
JDBC
JDBCJDBC
JDBC
 
3 database-jdbc(1)
3 database-jdbc(1)3 database-jdbc(1)
3 database-jdbc(1)
 
JDBC (2).ppt
JDBC (2).pptJDBC (2).ppt
JDBC (2).ppt
 
Jdbc ja
Jdbc jaJdbc ja
Jdbc ja
 
jdbc_presentation.ppt
jdbc_presentation.pptjdbc_presentation.ppt
jdbc_presentation.ppt
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
 

Plus de Dipayan Sarkar

introduction to aep arc
introduction to aep arcintroduction to aep arc
introduction to aep arcDipayan Sarkar
 
why focus on adolescents unique needs
why focus on adolescents unique needswhy focus on adolescents unique needs
why focus on adolescents unique needsDipayan Sarkar
 
aep in india milestones, learning, way forward
aep in india milestones, learning, way forwardaep in india milestones, learning, way forward
aep in india milestones, learning, way forwardDipayan Sarkar
 
Softskills - S Fernandez
Softskills - S FernandezSoftskills - S Fernandez
Softskills - S FernandezDipayan Sarkar
 
Project Based Learning- Ashish K Chaurdia
Project Based Learning- Ashish K ChaurdiaProject Based Learning- Ashish K Chaurdia
Project Based Learning- Ashish K ChaurdiaDipayan Sarkar
 
Linux and the Open Source- D Sarkar
Linux and the Open Source- D SarkarLinux and the Open Source- D Sarkar
Linux and the Open Source- D SarkarDipayan Sarkar
 
File Handling - N K Upadhyay
File Handling - N K UpadhyayFile Handling - N K Upadhyay
File Handling - N K UpadhyayDipayan Sarkar
 
Sorting Techniques - Govardhan Satish
Sorting Techniques - Govardhan SatishSorting Techniques - Govardhan Satish
Sorting Techniques - Govardhan SatishDipayan Sarkar
 
Application of Stack - Yadraj Meena
Application of Stack - Yadraj MeenaApplication of Stack - Yadraj Meena
Application of Stack - Yadraj MeenaDipayan Sarkar
 
Information Technology Act 2000 - Santosh K Pathak
Information Technology Act 2000 - Santosh K PathakInformation Technology Act 2000 - Santosh K Pathak
Information Technology Act 2000 - Santosh K PathakDipayan Sarkar
 
Universal Gates - Aneesa N Ali
Universal Gates - Aneesa N AliUniversal Gates - Aneesa N Ali
Universal Gates - Aneesa N AliDipayan Sarkar
 
Selection Sort - Vipin Ramola
Selection Sort - Vipin RamolaSelection Sort - Vipin Ramola
Selection Sort - Vipin RamolaDipayan Sarkar
 
Deletion of a Record from a File - K Karun
Deletion of a Record from a File - K KarunDeletion of a Record from a File - K Karun
Deletion of a Record from a File - K KarunDipayan Sarkar
 
Computer Viruses- B S Kalyan Chakravarthy
Computer Viruses- B S Kalyan ChakravarthyComputer Viruses- B S Kalyan Chakravarthy
Computer Viruses- B S Kalyan ChakravarthyDipayan Sarkar
 
Cloud Computing- Sreehari S
Cloud Computing- Sreehari SCloud Computing- Sreehari S
Cloud Computing- Sreehari SDipayan Sarkar
 

Plus de Dipayan Sarkar (18)

Relationships
RelationshipsRelationships
Relationships
 
ideal learning space
ideal learning spaceideal learning space
ideal learning space
 
introduction to aep arc
introduction to aep arcintroduction to aep arc
introduction to aep arc
 
why focus on adolescents unique needs
why focus on adolescents unique needswhy focus on adolescents unique needs
why focus on adolescents unique needs
 
aep in india milestones, learning, way forward
aep in india milestones, learning, way forwardaep in india milestones, learning, way forward
aep in india milestones, learning, way forward
 
Softskills - S Fernandez
Softskills - S FernandezSoftskills - S Fernandez
Softskills - S Fernandez
 
Project Based Learning- Ashish K Chaurdia
Project Based Learning- Ashish K ChaurdiaProject Based Learning- Ashish K Chaurdia
Project Based Learning- Ashish K Chaurdia
 
Linux and the Open Source- D Sarkar
Linux and the Open Source- D SarkarLinux and the Open Source- D Sarkar
Linux and the Open Source- D Sarkar
 
File Handling - N K Upadhyay
File Handling - N K UpadhyayFile Handling - N K Upadhyay
File Handling - N K Upadhyay
 
Sorting Techniques - Govardhan Satish
Sorting Techniques - Govardhan SatishSorting Techniques - Govardhan Satish
Sorting Techniques - Govardhan Satish
 
Application of Stack - Yadraj Meena
Application of Stack - Yadraj MeenaApplication of Stack - Yadraj Meena
Application of Stack - Yadraj Meena
 
Information Technology Act 2000 - Santosh K Pathak
Information Technology Act 2000 - Santosh K PathakInformation Technology Act 2000 - Santosh K Pathak
Information Technology Act 2000 - Santosh K Pathak
 
Universal Gates - Aneesa N Ali
Universal Gates - Aneesa N AliUniversal Gates - Aneesa N Ali
Universal Gates - Aneesa N Ali
 
Selection Sort - Vipin Ramola
Selection Sort - Vipin RamolaSelection Sort - Vipin Ramola
Selection Sort - Vipin Ramola
 
Deletion of a Record from a File - K Karun
Deletion of a Record from a File - K KarunDeletion of a Record from a File - K Karun
Deletion of a Record from a File - K Karun
 
Computer Viruses- B S Kalyan Chakravarthy
Computer Viruses- B S Kalyan ChakravarthyComputer Viruses- B S Kalyan Chakravarthy
Computer Viruses- B S Kalyan Chakravarthy
 
Cloud Computing- Sreehari S
Cloud Computing- Sreehari SCloud Computing- Sreehari S
Cloud Computing- Sreehari S
 
SQL JOINS- Reena P V
SQL JOINS- Reena P VSQL JOINS- Reena P V
SQL JOINS- Reena P V
 

Dernier

Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 

Dernier (20)

Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 

Java Databse Connectvity- Alex Jose

  • 3.
  • 4.  DriverManager Class : It is the class used to load JDBC Driver needed to access particular database.  Connection class : It manages the connection and communication to the database.  Statement Class: It contains the string that are submitted to the database for execution. And it will execute the SQL statement.  ResultSet Class : If the statement class contains select statement, then during the execution it will return selected rows from the database are assigned to ResultSet and it contains the methods to move through the rows and get the values.
  • 5.
  • 6.  Step1. import packages required for Database Programming.  Step2. Register the JDBC Driver.  Open a connection.  Execute a Query.  Extract data from the ResultSet.  Cleanup the environment.
  • 7. DESIGN THE INTERFACE AS PER REQUIREMENT
  • 8.  1. Import the packages required for Database Programming  import java.sql.*;  2. Register the JDBC Driver with Java Program.  Class.forName(“java.sql.DriverManager");  3. Open the connection.  This requires using the DriverManager.getConnection() method to create a connection object, which represents the physical connection with the database. To connect to the database, we need complete URL to the database with userid and password of MySQL.
  • 9.
  • 10.
  • 11.  4. Execute a query.  We need to create an object of type Statement or PreparedStatement for building and submitting an SQL statement to the database using the createStatement() function of Connection class.  in the Statement class executeQuery() method is needed to execute select statement in SQL and executeUpdate() method is to execute DML statements.  if the SQL command is Select statement we need a class called ResultSet to store and process the records.  The Result set refers to a logical set of records that are fetched from the database by executing a query and made available to the application program.
  • 12.  next()  moves the cursor forward one  first()  to move to the firts row.  last()  move the cursor to the lat lasr row.  relative(int rows)  moves the cursor relative to the current position.  absolute(int rno)  position the cursor on the rno th rows in the ResultSet.  getRow()  to get the current cursor position.
  • 13. Extract data from ResultSet  ResultSet class has several methods to get the values from the columns from the rows pointed by the cursor.  getInt("FieldName");  getString("FieldName"); getString(fieldNumber);  getFloat("FieldName");  getDate("FieldName");  getLong("FieldName");.
  • 14.
  • 16.  DefaultTableModel dtm=(javax.swing.table.DefaultTableModel)studenttab.getModel();  int rows=dtm.getRowCount();  if(rows>0)  {  for(int i=0;i<rows;i++)  {  dtm.removeRow(0);  }  }  try  {  Class.forName("java.sql.DriverManager");  Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/mydbll“,"root","");  Statement stmt=con.createStatement();  String str="select * from student";  ResultSet rs=stmt.executeQuery(str);  while(rs.next())  {  int sid=rs.getInt("stdid");  String sname= rs.getString("stdname"); int mark= rs.getInt(“mark");  Object obj[]={sid,sname,mark};  dtm.addRow(obj);   }  }  catch(Exception e)  {  System.out.println(e);  }
  • 17.  Executing the select statement having criteria.  String str=”select * from student where stdid=”+ t1.getText;  String str=”select * from student where stsname=’ ” + tname.getText() +” ’ ”;   To Execute DML commands  Int sid=Integer.parseInt(t1.getText());  String sname= tname.getText();  Int mark=Integer.parseInt(tmark.getText());  String str=”insert into student values(“+ sid+” , ’ “ + sname +” ’ , “+ mark +”)”;  Stmt.executeUpdate(str);  String str=”delete * from student where stdid=” + t1.getText() +”)”;  Stmt.executeUpdate(str);   String str=”update student set mark =mark+5 where stdname=’ ” + tname.getText() +” ’ )”;  Stmt.executeUpdate(str);