Before reading further, read the previous parts of this articles.
Now let's explain further about the procedure involved for an employee.
Transactions involved for an Authorized Employee

- Can check customer's details
- Can check his/her details
- Can change his/her password
Although there can be much more processes done for an employee like withdrawing money, updating customer details, and so on, but here we are just giving a few examples and all the rest you can try yourself.
The database schema table created for an employee is as in the following:

Now let's move to the coding part for an employee and database.
Code Example
EmployeeMain.java
- import java.sql.*;
- import java.io.*;
- import mydb.ConnectDB;
- class Employee {
- void Employee_dtl(String id){
- try{
- ConnectDB ob = new ConnectDB();
- Connection con = ob.c();
- Statement stm = con.createStatement();
- ResultSet rst = stm.executeQuery("select * from employee where EmpID ='"+id+"'");
- if(rst.next())
- {
- System.out.println("EmpID :"+id);
- System.out.println("Password :"+rst.getString("password"));
- System.out.println("Name :"+rst.getString("name"));
- System.out.println("Contact :"+rst.getString("contact"));
- System.out.println("Current Balance :"+rst.getDouble("balance"));
- System.out.println("Address :"+rst.getString("address"));
- }
- }
- catch(Exception e){
- System.out.println("Employee class display method"+e);
- } }
- void change_pass_emp(String id, String pass){
- try{
- BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
- ConnectDB ob = new ConnectDB();
- Connection con = ob.c();
- Statement stm = con.createStatement();
- System.out.println("Enter new password :");
- String p1=in.readLine();
- System.out.println("Confirm password :");
- String p2=in.readLine();
- if(p1.equals(p2))
- {
- stm.executeUpdate("update employee set password='"+p1+"' where EmpID='"+id+"' and password='"+pass+"'");
- System.out.println("password updated successfully...");
- }
- else
- {
- System.out.println("password does not match");
- }
- }
- catch(Exception e){
- System.out.println("Employee class change pass method"+e);
- }}
- void Cust_Details(String acc){
- try
- {
- ConnectDB ob = new ConnectDB();
- Connection con = ob.c();
- Statement stm = con.createStatement();
- ResultSet rst = stm.executeQuery("select * from customer where accno='"+acc+"'");
- Customer obj1=new Customer();
- obj1.display_Customer(acc);
- }
- catch(Exception e)
- {
- System.out.println("Employee see customer details method"+e);
- }
- }}
- public class EmployeeMain {
- public static void main(String[] args) throws Exception{
- try
- {
- BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
- System.out.println("Employee..??");
- System.out.println("1-Yes or 2-No");
- int choice0=Integer.parseInt(in.readLine());
- switch(choice0)
- {
- case 1:
- System.out.print("Enter the Employee Id: ");
- String id =in.readLine();
- System.out.print("Enter the password: ");
- String pass = in.readLine();
- ConnectDB ob = new ConnectDB();
- Connection conx = ob.c();
- Statement stmx = conx.createStatement();
- ResultSet rstx = stmx.executeQuery("Select * from employee where EmpID='"+id+"' and password='"+pass+"'");
- Employee objE =new Employee();
- if(rstx.next())
- {
- System.out.println("1-Display my details");
- System.out.println("2-Change password");
- System.out.println("3-Display customer details");
- System.out.print("Enter your choice: ");
- int choice1=Integer.parseInt(in.readLine());
- switch(choice1)
- {
- case 1:
- System.out.println("Enter the id Again: ");
- String idll =in.readLine();
- objE.Employee_dtl(idll);
- break;
- case 2:objE.change_pass_emp(id, pass);
- break;
- case 3:
- System.out.println("Enter Account number of customer: ");
- String acct = in .readLine();
- objE.Cust_Details(acct);
- break;
- default: System.out.println("wrong choice");
- }
- }
- else{
- System.out.println("Incorrect Match occur ");
- }
- break;
- default: System.out.println("Thank you");
- } }
- catch(Exception e)
- {
- System.out.println("main method:"+e);
- }
- }
- }








Santhakumar MunuswamyPosted Jun 2, 2015, 3:09 PM
Thanks for good one
NitinPosted Jun 2, 2015, 5:04 AM
nice
Gopi ChandPosted Jun 2, 2015, 4:44 AM
Thank you so much
Sibeesh VenuPosted Jun 2, 2015, 3:52 AM
Good one.
Abhishek JaiswalPosted Jun 2, 2015, 3:07 AM
Very well explained!! :)