Question
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.ResourceBundle; public class DbConnection { public static Connection getConnection() throws ClassNotFoundException, SQLException { ResourceBundle rb= ResourceBundle.getBundle(mysql); String url
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ResourceBundle;
public class DbConnection {
public static Connection getConnection() throws ClassNotFoundException, SQLException {
ResourceBundle rb= ResourceBundle.getBundle("mysql");
String url = rb.getString("db.url");
String username = rb.getString("db.username");
String password = rb.getString("db.password");
//fill the code
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class Main {
public static void main(String[] args) throws NumberFormatException, IOException, ClassNotFoundException, SQLException {
RoleDAO roleDAO = new RoleDAO();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrivilegeDAO privilegeDAO = new PrivilegeDAO();
List
System.out.println("List of privileges :");
System.out.format("%-15s %s ","Privilege ID","Privilege Name");
for(int i=0;i System.out.format("%-15s %s ",privileges.get(i).getId(),privileges.get(i).getName()); } System.out.println("Enter number of new Roles to be created :"); Integer n = Integer.parseInt(br.readLine()); System.out.println("Enter the role and privileges :"); //fill the code System.out.println("Enter the Role :"); String rol = br.readLine(); System.out.println("Privileges for "+rol+" :"); //fill the code } } db.url=jdbc:mysql://localhost:3306/role_privilege db.username=root db.password=test public class Privilege { private Integer id; private String name; public Privilege(){} public Privilege(String name){ this.name = name; } public Privilege(Integer id, String name) { this.id = id; this.name = name; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } } import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; public class PrivilegeDAO { public List //fill the code } } import java.util.ArrayList; public class Role { private Integer id; private String name; private ArrayList public Role(){} public Role(String name) { this.name = name; } public Role(Integer id, String name) { this.id = id; this.name = name; } public Role(Integer id, String name, ArrayList this.id = id; this.name = name; this.privilegeList = privilegeList; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public ArrayList return privilegeList; } public void setPrivilegeList(ArrayList this.privilegeList = privilegeList; } } import java.sql.*; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class RoleDAO { public void createRole(Role roleIns, ArrayList //fill the code } public List //fill the code } } drop table if exists privilege; create table privilege (id int not null AUTO_INCREMENT, name varchar(255) not null,primary key(id)); insert into privilege(name) values('Create'); insert into privilege(name) values('Process'); insert into privilege(name) values('Schedule'); insert into privilege(name) values('Cancel'); insert into privilege(name) values('View'); drop table if exists role; create table role (id int not null AUTO_INCREMENT, name varchar(255) not null,primary key(id)); drop table if exists role_privilege; create table role_privilege (role_id int not null references role(id), privilege_id int not null references privilege(id), primary key(role_id,privilege_id)); Use above code for implementation and refer Q10 image for complete question and specifiaction New Roles may emerge as the functionalities of the Shipment Management System expands. Wrte a program that will create
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