Question: 9 . 9 LAB - Database programming with Java 9 . 9 . 1 : LAB - Database programming with Java Complete the Java program
LAB Database programming with Java
: LAB Database programming with Java
Complete the Java program to create a Horse table, insert one row, and print the row.
Implement the following methods. Method parameters are described in the template. Do not modify the main program.
createConnection creates a connection to the database. This method calls DriverManager.getConnection with the following connection information:
User: root
Server address:
Database: zybooksdb
Password is not necessary and can be omitted.
createTable creates Horse, with five columns:
ID integer, primary key, not null
Name varchar
Breed varchar
Heightdouble
Birthdate varchar
Before creating Horse, drop the table if the table exists from a prior run
insertHorse inserts one row into Horse:
'Babe', 'Quarter horse',
selectAllHorses selects and prints all Horse rows, as follows:
All horses:
'Babe', 'Quarter Horse',
HINT: Use import java.sql to access all classes and methods of the JavaSQL API. Calls to these methods may throw exceptions and must be enclosed in the try block of a trycatch statement.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
