SlideShare a Scribd company logo
1 of 2
In Java choose a GUI component and either a DML or data retrieval statement, and give a code
example of how these would work together.
Solution
A data manipulation language ( DML ) is a family of syntax elements similar to a computer
programming language used for selecting, inserting, deleting and updating data in a database.
Performing read-only queries of data is sometimes also considered a component of DML .
The DML (Data Manipulation Language) statements INSERT, UPDATE and DELETE are used
to insert, update or delete data on the database respectively.
The DML operations of INSERT and UPDATE—that is, the write operations—are done by
means of the prepareStatement() method of the Connection object created above. A call to this
method takes variable bind parameters as input parameters and creates an object instance of
thePreparedStatement class.
The following line of code illustrates this:
String sql = "INSERT INTO emp VALUES (?,?,?,?,?,?,?,?)";PreparedStatement dml_stmt =
conn.prepareStatement(sql);
The input parameters are bound to this object instance using the setXXX() methods on
thePreparedStatement object. For each input bind parameter, a setXXX() method is called. Here
XXXstands for Int, String, and so on. The following line of code illustrates this:
Using Java Database Connectivity (JDBC) with Oracle
INSERT, UPDATE, and DELETE Operations Using JDBC
Prepared Statements
The DML operations of INSERT and UPDATE—that is, the write operations—are done by
means of the prepareStatement() method of the Connection object created above. A call to this
method takes variable bind parameters as input parameters and creates an object instance of
thePreparedStatement class.
The following line of code illustrates this:
String sql = "INSERT INTO emp VALUES (?,?,?,?,?,?,?,?)";PreparedStatement dml_stmt =
conn.prepareStatement(sql);
The input parameters are bound to this object instance using the setXXX() methods on
thePreparedStatement object. For each input bind parameter, a setXXX() method is called. Here
XXXstands for Int, String, and so on. The following line of code illustrates this:
The differences between Statement object and PreparedStatement object are the following:
A Statement object cannot accept bind parameters, whereas a PreparedStatement object can.
A PreparedStatement precompiles the SQL and hence the precompiled SQL statement can be
reused. In this way, it optimizes the database calls.
UPDATE and DELETE operations are similar to the INSERT operation described above.
However, if there are no bind parameters involved, a Statement object can be used instead of
aPreparedStatement object with the values hard-coded directly in the DML statement.

More Related Content

Similar to In Java choose a GUI component and either a DML or data retrieval stat.docx

Similar to In Java choose a GUI component and either a DML or data retrieval stat.docx (20)

Session06 handling xml data
Session06  handling xml dataSession06  handling xml data
Session06 handling xml data
 
Intake 37 ef2
Intake 37 ef2Intake 37 ef2
Intake 37 ef2
 
Simple ado program by visual studio
Simple ado program by visual studioSimple ado program by visual studio
Simple ado program by visual studio
 
Simple ado program by visual studio
Simple ado program by visual studioSimple ado program by visual studio
Simple ado program by visual studio
 
Ef code first
Ef code firstEf code first
Ef code first
 
Ado.net
Ado.netAdo.net
Ado.net
 
Spring framework part 2
Spring framework part 2Spring framework part 2
Spring framework part 2
 
Lecture17
Lecture17Lecture17
Lecture17
 
Jdbc sasidhar
Jdbc  sasidharJdbc  sasidhar
Jdbc sasidhar
 
ADO.NET by ASP.NET Development Company in india
ADO.NET by ASP.NET  Development Company in indiaADO.NET by ASP.NET  Development Company in india
ADO.NET by ASP.NET Development Company in india
 
Database Access With JDBC
Database Access With JDBCDatabase Access With JDBC
Database Access With JDBC
 
Jdbc tutorial
Jdbc tutorialJdbc tutorial
Jdbc tutorial
 
Using Spark to Load Oracle Data into Cassandra (Jim Hatcher, IHS Markit) | C*...
Using Spark to Load Oracle Data into Cassandra (Jim Hatcher, IHS Markit) | C*...Using Spark to Load Oracle Data into Cassandra (Jim Hatcher, IHS Markit) | C*...
Using Spark to Load Oracle Data into Cassandra (Jim Hatcher, IHS Markit) | C*...
 
Using Spark to Load Oracle Data into Cassandra
Using Spark to Load Oracle Data into CassandraUsing Spark to Load Oracle Data into Cassandra
Using Spark to Load Oracle Data into Cassandra
 
JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
 
Chapter Seven- JDBC.pptx
Chapter Seven- JDBC.pptxChapter Seven- JDBC.pptx
Chapter Seven- JDBC.pptx
 
ADO.NET
ADO.NETADO.NET
ADO.NET
 
Dao pattern
Dao patternDao pattern
Dao pattern
 
3-ADO.NET.pdf
3-ADO.NET.pdf3-ADO.NET.pdf
3-ADO.NET.pdf
 
Csharp_dotnet_ADO_Net_database_query.pptx
Csharp_dotnet_ADO_Net_database_query.pptxCsharp_dotnet_ADO_Net_database_query.pptx
Csharp_dotnet_ADO_Net_database_query.pptx
 

More from mckerliejonelle

WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docx
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docxWHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docx
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docx
mckerliejonelle
 

More from mckerliejonelle (20)

What was ABC Inc's net capital spending in the year 2022- given their.docx
What was ABC Inc's net capital spending in the year 2022- given their.docxWhat was ABC Inc's net capital spending in the year 2022- given their.docx
What was ABC Inc's net capital spending in the year 2022- given their.docx
 
What subatomic partichis ate located in the nuicleas of an atom- nesif.docx
What subatomic partichis ate located in the nuicleas of an atom- nesif.docxWhat subatomic partichis ate located in the nuicleas of an atom- nesif.docx
What subatomic partichis ate located in the nuicleas of an atom- nesif.docx
 
what type of decision making style do well in environments where there.docx
what type of decision making style do well in environments where there.docxwhat type of decision making style do well in environments where there.docx
what type of decision making style do well in environments where there.docx
 
What skills have you gained that would be applied to a computer techno.docx
What skills have you gained that would be applied to a computer techno.docxWhat skills have you gained that would be applied to a computer techno.docx
What skills have you gained that would be applied to a computer techno.docx
 
What pattern of inheritance does variant have with the RCH gene at the.docx
What pattern of inheritance does variant have with the RCH gene at the.docxWhat pattern of inheritance does variant have with the RCH gene at the.docx
What pattern of inheritance does variant have with the RCH gene at the.docx
 
What percentage of genetic divergence is used to define separate speci.docx
What percentage of genetic divergence is used to define separate speci.docxWhat percentage of genetic divergence is used to define separate speci.docx
What percentage of genetic divergence is used to define separate speci.docx
 
What makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docx
What makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docxWhat makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docx
What makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docx
 
What motivates radical environmentalist groups like the Earth Liberati.docx
What motivates radical environmentalist groups like the Earth Liberati.docxWhat motivates radical environmentalist groups like the Earth Liberati.docx
What motivates radical environmentalist groups like the Earth Liberati.docx
 
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docx
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docxWHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docx
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docx
 
What is true about the relative concentration of H+ and OH- in water-.docx
What is true about the relative concentration of H+ and OH- in water-.docxWhat is true about the relative concentration of H+ and OH- in water-.docx
What is true about the relative concentration of H+ and OH- in water-.docx
 
What is the result (in binary) of adding the unsigned char binary numb.docx
What is the result (in binary) of adding the unsigned char binary numb.docxWhat is the result (in binary) of adding the unsigned char binary numb.docx
What is the result (in binary) of adding the unsigned char binary numb.docx
 
What is the resolution of a digital-to-analog converter (DAC)- It is t.docx
What is the resolution of a digital-to-analog converter (DAC)- It is t.docxWhat is the resolution of a digital-to-analog converter (DAC)- It is t.docx
What is the resolution of a digital-to-analog converter (DAC)- It is t.docx
 
What is the primary reason that Earth is cold at the poles and hot at.docx
What is the primary reason that Earth is cold at the poles and hot at.docxWhat is the primary reason that Earth is cold at the poles and hot at.docx
What is the primary reason that Earth is cold at the poles and hot at.docx
 
What is the main differentiating factor of an Advanced Alternative Pay.docx
What is the main differentiating factor of an Advanced Alternative Pay.docxWhat is the main differentiating factor of an Advanced Alternative Pay.docx
What is the main differentiating factor of an Advanced Alternative Pay.docx
 
What is the main difterence between Al- ML- and OL- Select ones a- ML.docx
What is the main difterence between Al- ML- and OL- Select ones a- ML.docxWhat is the main difterence between Al- ML- and OL- Select ones a- ML.docx
What is the main difterence between Al- ML- and OL- Select ones a- ML.docx
 
What is the function of helper T cells in cell mediated immunity- Kill.docx
What is the function of helper T cells in cell mediated immunity- Kill.docxWhat is the function of helper T cells in cell mediated immunity- Kill.docx
What is the function of helper T cells in cell mediated immunity- Kill.docx
 
What is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docx
What is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docxWhat is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docx
What is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docx
 
What is the effect of cholesterol on membrane fluidity at physiologic.docx
What is the effect of cholesterol on membrane fluidity at physiologic.docxWhat is the effect of cholesterol on membrane fluidity at physiologic.docx
What is the effect of cholesterol on membrane fluidity at physiologic.docx
 
What is the default IP Prefix for a Class A- -16 124 130 18.docx
What is the default IP Prefix for a Class A- -16 124 130 18.docxWhat is the default IP Prefix for a Class A- -16 124 130 18.docx
What is the default IP Prefix for a Class A- -16 124 130 18.docx
 
What is the biggest animal in the world- What is the only active volca.docx
What is the biggest animal in the world- What is the only active volca.docxWhat is the biggest animal in the world- What is the only active volca.docx
What is the biggest animal in the world- What is the only active volca.docx
 

Recently uploaded

An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Recently uploaded (20)

An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
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
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 

In Java choose a GUI component and either a DML or data retrieval stat.docx

  • 1. In Java choose a GUI component and either a DML or data retrieval statement, and give a code example of how these would work together. Solution A data manipulation language ( DML ) is a family of syntax elements similar to a computer programming language used for selecting, inserting, deleting and updating data in a database. Performing read-only queries of data is sometimes also considered a component of DML . The DML (Data Manipulation Language) statements INSERT, UPDATE and DELETE are used to insert, update or delete data on the database respectively. The DML operations of INSERT and UPDATE—that is, the write operations—are done by means of the prepareStatement() method of the Connection object created above. A call to this method takes variable bind parameters as input parameters and creates an object instance of thePreparedStatement class. The following line of code illustrates this: String sql = "INSERT INTO emp VALUES (?,?,?,?,?,?,?,?)";PreparedStatement dml_stmt = conn.prepareStatement(sql); The input parameters are bound to this object instance using the setXXX() methods on thePreparedStatement object. For each input bind parameter, a setXXX() method is called. Here XXXstands for Int, String, and so on. The following line of code illustrates this: Using Java Database Connectivity (JDBC) with Oracle INSERT, UPDATE, and DELETE Operations Using JDBC Prepared Statements The DML operations of INSERT and UPDATE—that is, the write operations—are done by means of the prepareStatement() method of the Connection object created above. A call to this method takes variable bind parameters as input parameters and creates an object instance of thePreparedStatement class.
  • 2. The following line of code illustrates this: String sql = "INSERT INTO emp VALUES (?,?,?,?,?,?,?,?)";PreparedStatement dml_stmt = conn.prepareStatement(sql); The input parameters are bound to this object instance using the setXXX() methods on thePreparedStatement object. For each input bind parameter, a setXXX() method is called. Here XXXstands for Int, String, and so on. The following line of code illustrates this: The differences between Statement object and PreparedStatement object are the following: A Statement object cannot accept bind parameters, whereas a PreparedStatement object can. A PreparedStatement precompiles the SQL and hence the precompiled SQL statement can be reused. In this way, it optimizes the database calls. UPDATE and DELETE operations are similar to the INSERT operation described above. However, if there are no bind parameters involved, a Statement object can be used instead of aPreparedStatement object with the values hard-coded directly in the DML statement.