Study the user interface given below and complete the code as per instructions. The UI designed below is part of a POS s
Posted: Sat Nov 27, 2021 2:38 pm
application below.
Study the user interface given below and complete the code as per instructions. The UI designed below is part of a POS systems to add products of sale to the company database. For this function to work, the user needs to provide the following information: product ID, product name, price and quantity available in stock. Once the SAVE button is pressed – this information is stored in the database. The DELETE button deletes the product by ID listed. ProductID Product Name Product Price Quantity DELETE SAVE E • database name "products" • table name = "product_details"
Field name and Type: • Product_ID • Name • Quantity • Price VarChar VarChar Integer Double You have been asked to implement this system as a Java RMI application. The Server application has already been written for you. import java.rmi.*; import java.rmi.server.*; import java.rmi.registry.*; public class Server extends DBFuncImpl { Server() throws Exception { super(); } public static void main(String[] args) throws Exception { 1 try 2 { //instantiate the implementation class DBFuncImpl stub = new DBFuncImpl(); //Bind the remote object (stub) in the registry Registry reg = LocateRegistry.createRegistry (9999); reg.rebind("myDBServer", stub);
Code the following: • Code the remote interface. (4 Marks) • Provide the implementation of the remote interface. A partial code is provided for you. (8 Marks) public class DBFuncImpl extends UnicastRemoteobject implements DBFuncInt { public DBFuncImpl() throws Exception super(); ) public static Connection getConnection() throws SQLException Connection conn = null; String username = "root"; String password = ""; String url = "jdbc:mysql://localhost: 3306/products"; try Class.forName ("com.mysql.jdbc.Driver"); //establish a connection to database conn = DriverManager.getConnection (url, username, password); } catch (Exception e) { System.out.println(e.getMessage()); } return conn; ) public void saveproduct (String queryString) //complete the implementation ) public void deleteproduct (String queryString) // complete the implementation