Question: Write a JDBC program to support the following functions: List all writing groups List all the data for a group specified by the user .
Write a JDBC program to support the following functions:
List all writing groups
List all the data for a group specified by the user . This includes all the data for the associated books and publishers.
List all publishers
List all the data for a pubisher specified by the user. This includes all the data for the associated books and writing groups.
List all book titles
List all the data for a book specified by the user. This includes all the data for the associated publisher and writing group.
Insert a new book
Insert a new publisher and update all book published by one publisher to be published by the new pubisher. This requirement is two separate operations. The idea is that a new publisher, (xyz) buys out an existing publisher (abc). After the new publisher is added to the database, all books that are currently published by abc will now be published by xyz.
Remove a book specified by the user
For all queries involving user input, you must use prepared statements
You must be able to prove your results after each query
Make sure to validate the data either through the java code or database constraints
Make sure you handle any SQLExceptions that are thrown
-- the sql code is :
1)Create Writting Group Table :-
CREATE TABLE `WritingGroups` ( `GroupName` VARCHAR(256) NOT NULL, `HeadWritter` VARCHAR(256) NOT NULL, `YearFormed` VARCHAR(45) NOT NULL, `Subject` VARCHAR(256) NOT NULL, PRIMARY KEY (`GroupName`) );
2) Create Publishers Table:-
CREATE TABLE `Publishers` ( `PublisherName` VARCHAR(256) NOT NULL, `PublisherAddress` TEXT NOT NULL, `PublisherPhone` VARCHAR(256) NOT NULL, `PublisherEmail` VARCHAR(256) NOT NULL, PRIMARY KEY (`PublisherName`) );
3) Create Books Table
CREATE TABLE `Books` ( `GroupName` varchar(256) NOT NULL, `BookTitle` varchar(256) NOT NULL, `PublisherName` varchar(256) NOT NULL, `YearPublished` varchar(45) NOT NULL, `NumberPages` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`GroupName`,`BookTitle`), KEY `PublisherNameFk_idx` (`PublisherName`), CONSTRAINT `GroupNameFK` FOREIGN KEY (`GroupName`) REFERENCES `WritingGroups` (`GroupName`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `PublisherNameFk` FOREIGN KEY (`PublisherName`) REFERENCES `Publishers` (`PublisherName`) ON DELETE NO ACTION ON UPDATE NO ACTION )
Step by Step Solution
There are 3 Steps involved in it
To implement this JDBC program we will follow a structured approach tailored to fulfill each requirement Step 1 Set up the Environment Ensure that you have a Java Development Kit JDK installed Include ... View full answer
Get step-by-step solutions from verified subject matter experts
