Home /
Expert Answers /
Computer Science /
create-a-java-server-that-performs-queries-on-the-database-from-exercise-1-this-server-will-simpl-pa705
(Solved):
Create a Java Server that performs queries on the database from Exercise 1. This server will simpl ...
Create a Java Server that performs queries on the database from Exercise 1. This server will simply connect to the database and then perform queries. The results of each query must be returned as shown in the list of required methods bebw. In the IDE of your choize, create a new Java project (if required) and within that create a fava class calkd ResitPaper. In your project you will need to add the external jar k postgresql-42.3.5.jar that you can downbad from: https://jdbc.postgresq 1 . or \( \mathrm{g} / \mathrm{d} \) ownload. htm 1 . The package declaration for this class must be: 3 In your ResitPaper class create the following constants: private static striag dbconaad = "jdbc:postgresql://127.0.0.1:5432/resitpa privat e at at ic string ua er \( = \) inad"; private at atic String po = "fadio22"i To connect to this database, create a static method connectionatabase using the fo llowing code: try \{ Claza.forllan ("arg.postgreaql. Driver"); / /clasapath obile conpiliag cona - Driverllanager get Conacction ( dbconand, db, pe); ; \}cat ch (Exception e) \{ e. priatstackirace(); ] Where conn is a reference of type C onnection, which is part of the java.sql package. Make sure you import all the needed elements. [4 marks] \( \begin{array}{ll}\text { Add the code to declare the new enum type sizeType. } & \text { [2 marks] } \\ \text { Add the code to declare the new enum type colkct ionType. } & \text { [2 marks] }\end{array} \) Add the following methods to yourclass. Foreach method you must write the SQL that will give the required result and then retrieve the result of that query from the database. public roid addstare(string poatcode, String City) This method regíters a new store. You will need to generate the new Storeid as per the rules of Exercise \( 1 . \) [4 marks] public roid addided(string Modelid, String hodeltype, collectiontype Collection, int Productionear) This method registers a new model. You will need to generate the new collectiontype as per the rules of Exercise 1. Beware of the casting to colkctionType. [4 marks] public roid additen(String Itenid, string hadelid, int stareid, String Color, aizetype Size, Bigdecial Price) This method declares a new item as part of the inventory of a store. You will need to generate the new sizetype as per the rules of Exercise 1. Make sure you check that the ItemID first 2 digits and the size match adequately. Do not worry about matching the
Here is your answer //Here I have used the MySQL Database and the code is executing and I have demonstrated every important line of code line import java.sql.*; public class JDBCExample { private static String url; public static void main(String args