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. */ } }
Determine the Output: Package questions; import java.util.*; public class Quiz1 {       public static void main(String[] args)...
Determine the Output: Package questions; import java.util.*; public class Quiz1 {       public static void main(String[] args) {             // TODO Auto-generated method stub             System.out.println("*** 1 ***");             ArrayList<Integer>list1=new ArrayList<Integer>();             for(int i=0;i<30;i++)             {                   list1.add(new Integer(i));             }             System.out.print("[");             for(int i=0;i<list1.size();i++)             {                   System.out.print(list1.get(i)+" ");             }             System.out.println("]");                           System.out.println("*** 2 ***");             ArrayList<Integer>list2=new ArrayList<Integer>();             for(int i=30;i<60;i++)             {                   list2.add(i); //Auto Boxing an Integer not need to use new Integer             }             System.out.println(list2); //toString for an ArrayList --created by the Java Programmers                           System.out.println("*** 3 ***");             ArrayList<Integer>list3=new ArrayList<Integer>();             list3.add(list1.remove(22)); //when...
//package Lab7_2_LinkedList_Sol; public class Runner { public static void main(String[] args){ MyLinkedList ll = new MyLinkedList(10.1);...
//package Lab7_2_LinkedList_Sol; public class Runner { public static void main(String[] args){ MyLinkedList ll = new MyLinkedList(10.1); ll.append(10.5); ll.append(8.11); ll.append(15.6); System.out.println("--------Printing via print method------------"); ll.print(); System.out.println("--------Printing via initiator------------"); ll.initiateIterator(); Object o = null; while ( (o=ll.nextObject())!=null){ System.out.println((Double)(o)); } ll.initiateIterator(); Object largest=ll.nextObject(); while (((o=ll.nextObject())!=null)){ if ((Double)o>(Double)largest) largest=o; } System.out.println("The largest number in the LL is: "+largest); System.out.println("--------Number insertion------------"); ll.insert(100.2145, 4); ll.insert(110.2145, 0); ll.insert(120.2145, 2); ll.insert(180.2145, 8); ll.print(); System.out.println("--------Removal------------"); int ind=3; System.out.println("Removal of pos "+ind+" is: "+ll.remove(ind)); ll.print(); ind=5; System.out.println("Removal of pos "+ind+"...
Design an application with a single class and two static methods: method main and method isLeap....
Design an application with a single class and two static methods: method main and method isLeap. Static method isLeap accepts year as integer and returns boolean value true or false depending whether year is leap or not. public static boolean isLeap ( int year ) The year is leap year if it is divisible by 4, but not divisible by 100 except if it is divisible by 400. Examples 2007 is not a leap year 2008 is leap year 1700...
could you do all the challenges? public class Main { public static void main(String[] args) {...
could you do all the challenges? public class Main { public static void main(String[] args) { // declare an array so you can easily use them under // one name //ex1 array of test score 0-100 int[] testScores = new int[100]; //ex2 array of 200 gpa double[] gpa = new double[200]; //ex3 50 element array of age int[] age; //1 - declares age array age = new int[50]; //2 - instantiates age array age[0] = 10; //3 - put initial...
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? 
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT