Question
JAVA CONSIDER THIS CSV FILE Name, Alex, Bert, Carl, Dave, Elly, Fran, Gwen, Hank, Ivan, Jake, Kate, Luke, Myra, Neil, Omar, Page, Quin, Ruth, Sex,
JAVA
CONSIDER THIS CSV FILE
"Name", "Alex", "Bert", "Carl", "Dave", "Elly", "Fran", "Gwen", "Hank", "Ivan", "Jake", "Kate", "Luke", "Myra", "Neil", "Omar", "Page", "Quin", "Ruth", "Sex", "Age", "Height (in)", "Weight (lbs)" "M", 41, 74, 170 "M", 42, 68, 166 "M", 32, 70, 155 "M", 39, 72, 167 "F", 30, 66, 124 "F", 33, 66, 115 "F", 26, 64, 121 "M", 30, 71, 158 "M", 53, 72, 175 "M", 32, 69, 143 "F", 47, 69, 139 "M", 34, 72, 163 "F", 23, 62, 98 "M", 36, 75, 160 "M", 38, 70, 145 "F", 31, 67, 135 "M", 29, 71, 176 "F", 28, 65, 131
a. Create a class TestJDB1 with a test() method that will be able to connect to an in-memory embedded h2 database (driver provided in the subject folder) b. Complete the test() method by preparing a statement that will create the table PERSONS with the appropriate columns names, types, and constraints (you can add an auto_increment feature on a new id column) c. Invoke that test() method in the main method of your launcher class // Previous code TestJDB1.test() ; Hints - - - To setup the connection, you need to include the h2 jdbc driver as seen during lectures. When using eclipse, you have to go in the Project Properties > Build Path and add the h2 jar (provided in the subject folder) in the Libraries tab. To open a connection in an in-memory h2 database, one have to connect to this url: jdbc:h2:mem:testdb Important : remember that the in-memory db will lose all the data between two connections, so beware to reuse the same connection or you will get unexpected behavior. Exercise JDB2 20 minutes 3pt a. Create a PersonJDBCDAO class that will contain a create() and a search() methods b. Write a TestJDB2 test class that will gather the following operations: 1. From the csv file, read the persons list 2. For each person in the list, call the create() method from the PersonJDBCDAO 3. Call the search() method to validate the fact that everything is well inserted. 4. Display the result list in the console c. Add the following code to your launcher main method // Previous code TestJDB2.test() ;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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