Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import java.sql.*; public class DBTesterApp { private static Connection connection; public static void main(String args[]) {
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.
Step by Step Solution
★★★★★
3.34 Rating (154 Votes )
There are 3 Steps involved in it
Step: 1
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...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started