Question

In: Computer Science

package design; public class FortuneEmployee { /** * FortuneEmployee class has a main methods where you...

package design;

public class FortuneEmployee {

   /**
    * FortuneEmployee class has a main methods where you will be able to create Object from
    * EmployeeInfo class to use fields and attributes.Demonstrate as many methods as possible 
    * to use with proper business work flow.Think as a Software Architect, Product Designer and 
    * as a Software Developer.(employee.info.system) package is given as an outline,you need to elaborate
    * more to design an application that will meet for fortune 500 Employee Information
    * Services.
    *
    * Use any databases[MongoDB, Oracle, MySql] to store data and retrieve data.
    *
    **/
   public static void main(String[] args) {
      


   }

}

Solutions

Expert Solution

package employee.info.system;

import java.io.*;

import javax.servlet.*;

import javax.servlet.http.*;

import java.sql,*;

public class EmployeeInfo{

private int Emp_id;

private String Emp_name;

private int Emp_age;

public int getid(){

return Emp_id;

}

public void setid(){

this.Emp_id=Emp_id;

}

public String getname(){

return Emp_name;

}

public void setname(){

this.Emp_name=Emp_name;

}

public int getage(){

return Emp_age;

}

public void setage(){

this.Emp_age=Emp_age;

}

}

public class FortuneEmployee extends HttpServlet

{

public void doGet(HttpServletRequest req,HttpServletResponse res) throws IoException,ServletException

{

ResultSet rs;

PrintWriter out=res.getWriter();

res.setContentType("text/html");

out.println("<html><body>");

try

{

EmployeeInfo info=new EmployeeInfo();

info.setid(Integer.parseInt(request.getParameter("Emp_id")));

Class.forName("oracle.jdbc.driver.OdbcDriver");

Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe"."system","abc123");

PreparedStatement ps=con.prepareStatement("Select * from employee where Emp_id=?");

rs=ps.executeQuery();

ps.setInt(1,info.getid());

out.println("table border=1 width=50% height=50%>");

out.println("<tr><th>Employee name</th><th>Employee age</th></tr>");

while(rs.next())

{

String name=rs.getString("Emp_name");

int age=rs.getInt("Emp_age");

out.println("<tr><td>" + name + "</td><td>" + age + " </td> </tr>");

}

out.println("</table>);

out.println("</html></body>");

con.close();

}

catch(Exception e)

{

out.println("error");

}

}

}

In the above program by using servlets in java i retrieved the information of an employee from employee table which is stored in oracle database and dispalyed employee information in the table format on the screen.


Related Solutions

package datastructure; public class UseQueue { public static void main(String[] args) { /* * Demonstrate how...
package datastructure; public class UseQueue { public static void main(String[] args) { /* * Demonstrate how to use Queue that includes add,peek,remove,pool elements. * Use For Each loop and while loop with Iterator to retrieve data. * */ } }
package datastructure; public class UseMap { public static void main(String[] args) { /* * Demonstrate how...
package datastructure; public class UseMap { public static void main(String[] args) { /* * Demonstrate how to use Map that includes storing and retrieving elements. * Add List<String> into a Map. Like, Map<String, List<string>> list = new HashMap<String, List<String>>(); * Use For Each loop and while loop with Iterator to retrieve data. * * Use any databases[MongoDB, Oracle, MySql] to store data and retrieve data. */ } }
public class Main { public static void main(String [] args) { int [] array1 = {5,...
public class Main { public static void main(String [] args) { int [] array1 = {5, 8, 34, 7, 2, 46, 53, 12, 24, 65}; int numElements = 10; System.out.println("Part 1"); // Part 1 // Enter the statement to print the numbers in index 5 and index 8 // put a space in between the two numbers and a new line at the end // Enter the statement to print the numbers 8 and 53 from the array above //...
---------------------------------------------------------------------------- public class Main { public static void main(String[] args) { int[] A = {11, 12,...
---------------------------------------------------------------------------- public class Main { public static void main(String[] args) { int[] A = {11, 12, -10, 13, 9, 12, 14, 15, -20, 0}; System.out.println("The maximum is "+Max(A)); System.out.println("The summation is "+Sum(A)); } static int Max(int[] A) { int max = A[0]; for (int i = 1; i < A.length; i++) { if (A[i] > max) { max = A[i]; } } return max; } static int Sum(int[] B){ int sum = 0; for(int i = 0; i --------------------------------------------------------------------------------------------------------------------------- Convert...
Fix the following java code package running; public class Run {    public double distance; //in...
Fix the following java code package running; public class Run {    public double distance; //in kms    public int time; //in seconds    public Run prev;    public Run next;    //DO NOT MODIFY - Parameterized constructor    public Run(double d, int t) {        distance = Math.max(0, d);        time = Math.max(1, t);    }       //DO NOT MODIFY - Copy Constructor to create an instance copy    //NOTE: Only the data section should be...
What is a package? What package is the Scanner class in? What package is the String class in?
What is a package? What package is the Scanner class in? What package is the String class in? 
Could you do it with python please? public class BSTTraversal {         public static void main(String[]...
Could you do it with python please? public class BSTTraversal {         public static void main(String[] args) {                 /**                  * Creating a BST and adding nodes as its children                  */                 BSTTraversal binarySearchTree = new BSTTraversal();                 Node node = new Node(53);                 binarySearchTree.addChild(node, node, 65);                 binarySearchTree.addChild(node, node, 30);                 binarySearchTree.addChild(node, node, 82);                 binarySearchTree.addChild(node, node, 70);                 binarySearchTree.addChild(node, node, 21);                 binarySearchTree.addChild(node, node, 25);                 binarySearchTree.addChild(node, node, 15);                 binarySearchTree.addChild(node, node, 94);                 /**         ...
You are given the following class definition (assume all methods are correctly implemented): public class Song...
You are given the following class definition (assume all methods are correctly implemented): public class Song { ... public Song(String name, String artist) { ... } public String getName() { ... } public String getArtist() { ... } public String getGenre() { ... } public int copiesSold() { ... } } Write NAMED and TYPED lambda expressions for each of the following, using appropriate functional interfaces from the java.util.function and java.util packages (Only the lambda expression with no type+name will...
You are given the following class definition (assume all methods are correctly implemented): public class Song...
You are given the following class definition (assume all methods are correctly implemented): public class Song { ... public Song(String name, String artist) { ... } public String getName() { ... } public String getArtist() { ... } public String getGenre() { ... } public int copiesSold() { ... } } Write NAMED and TYPED lambda expressions for each of the following, using appropriate functional interfaces from the java.util.function and java.util packages (Only the lambda expression with no type+name will...
------------------------------------------------------------------------------------ import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input =...
------------------------------------------------------------------------------------ import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int result = 0; System.out.print("Enter the first number: "); int x = input.nextInt(); System.out.print("Enter the second number: "); int y = input.nextInt(); System.out.println("operation type for + = 0"); System.out.println("operation type for - = 1"); System.out.println("operation type for * = 2"); System.out.print("Enter the operation type: "); int z = input.nextInt(); if(z==0){ result = x + y; System.out.println("The result is " + result); }else...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT