import java.sql.*; public class DBTesterApp { private static Connection connection; public static void
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
write JDBC code that works with the SQLite database named products.sqlite that was described in the previous chapter. Review the code and test the application 1. Open the project named ch21_ex1_DBTester that's in the ex_starts folder. 2. Expand the Libraries folder for this project and note that it includes a JAR file for the SQLite database driver. If it doesn't include this driver, add the SQLite driver that's in the java/db directory of the download for this book. 3. Open the DB Tester class and review its code. Note that it connects to the database named products.sqlite that's in the application's root directory. 4. Run the project. It should print all of the rows in the Products table to the console three times with some additional messages. Write and test code that uses JDBC 5. Write the code for the printFirstProduct() method. This method should print the first product in the list of products to the console. Use column names to retrieve the column values. 6. Run this application to make sure it's working correctly. 7. Write the code for the printProductByCode() method. This method should print the product with the specified code to the console. Use a prepared statement to create the result set, and use indexes to retrieve the column values. 8. Run this application to make sure it's working correctly. 9. Write the code for the insert Product() method. This method should add the product to the database and print that product to the console. 10. Run this application to make sure it's working correctly. If you run this application multiple times, it should display an error message that indicates that the product can't be added because of a duplicate key. 11. Write the code for the deleteProduct() method. This method should delete the product that was added by the insert Product() method. 12. Run this application to make sure it's working correctly. You should be able to run this application multiple times without it displaying any error messages. write JDBC code that works with the SQLite database named products.sqlite that was described in the previous chapter. Review the code and test the application 1. Open the project named ch21_ex1_DBTester that's in the ex_starts folder. 2. Expand the Libraries folder for this project and note that it includes a JAR file for the SQLite database driver. If it doesn't include this driver, add the SQLite driver that's in the java/db directory of the download for this book. 3. Open the DB Tester class and review its code. Note that it connects to the database named products.sqlite that's in the application's root directory. 4. Run the project. It should print all of the rows in the Products table to the console three times with some additional messages. Write and test code that uses JDBC 5. Write the code for the printFirstProduct() method. This method should print the first product in the list of products to the console. Use column names to retrieve the column values. 6. Run this application to make sure it's working correctly. 7. Write the code for the printProductByCode() method. This method should print the product with the specified code to the console. Use a prepared statement to create the result set, and use indexes to retrieve the column values. 8. Run this application to make sure it's working correctly. 9. Write the code for the insert Product() method. This method should add the product to the database and print that product to the console. 10. Run this application to make sure it's working correctly. If you run this application multiple times, it should display an error message that indicates that the product can't be added because of a duplicate key. 11. Write the code for the deleteProduct() method. This method should delete the product that was added by the insert Product() method. 12. Run this application to make sure it's working correctly. You should be able to run this application multiple times without it displaying any error messages.
Expert Answer:
Answer rating: 100% (QA)
The image contains instructions for running and testing a Java application that interacts with an SQLite database as well as writing and testing Java Database Connectivity JDBC code for the applicatio... View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
(a) Use the following text to derive distributions for rat and chased. Use a five-word window, including open- and closed- class words, ignore case, punctuation and sentence boundaries and weight...
-
Can someone help me understand why this code isn't working. The code is a flight seating plan. Chart: /* * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this...
-
In this question assume that p and q are atomic formulae. (a) Compare and contrast path formulae and state formulae in temporal logic. [4 marks] (b) Describe and contrast the meanings of F(G p) and...
-
When a manager greets department visitors or attends ceremonies, he or she is playing the role of: Figurehead Conceptual Empowerment Productivity
-
At room temperature and pressure RbI crystallizes with the NaCl-type structure. (a) Use ionic radii to predict the length of the cubic unit cell edge. (b) Use this value to estimate the density. (c)...
-
Youre trying to save to buy a new $275,000 Ferrari. You have $50,000 today that can be invested at your bank. The bank pays 4.8 percent annual interest on its accounts. How long will it be before you...
-
Derringer and Suich ("Simultaneous Optimization of Several Response Variables," Journal of Quality Technology, 1980) studied the relationship of an abrasion index for a tire tread compound in terms...
-
All of the deviations listed in E8-1 and E8-2 took place, and 1,100 units were started and finished. In E8-1 1,000 units were started and finished. Case 1: All prices and quantities for the cost...
-
Houston - based Advanced Electronics manufactures audio speakers for desktop computers. The following data relate to the period just ended when the company produced and sold 4 1 , 0 0 0 speaker sets:...
-
Choose any one law or policy associated with homeland security or emergency management and do the following: Evaluate the selected policy in terms of whether it is a carrot, a whip, a sermonor a...
-
Describe the major benefits and limitations of thick clientserver architectures.
-
An average cost curve is found to be AC = 89.96 + 0.0179Q2 2.294Q. At what level of output is average cost minimized?
-
How do you specify a methods algorithm? Give an example of an algorithm specification for a compute pay method associated with an hourly employee class using Structured English.
-
What are the advantages of using an OODBMS over an ORDBMS?
-
Define scalable. Why is this term important to system developers?
-
Write a persuasive e-mail. You are the East Coast manager of a Fortune 500 company. The company CEO just informed you that your branch consistently has a 300% higher shipping costs overruns. Write an...
-
A regular deposit of $100 is made at the beginning of each year for 20 years. Simple interest is calculated at i% per year for the 20 years. At the end of the 20-year period, the total interest in...
-
Reflect on how the 'pair-wise' criterion system could be applied in your organisation. Against which criterion would you carry out prioritisation?
-
Using the BCG matrix illustrated in Figure 4. 13 review the investments from the list below. Investment $\mathrm{A}$ is a new product that has been released into the industry. It seems to be...
-
What are important considerations in designing a project approach?
Study smarter with the SolutionInn App