5.2 Creating a Java Bean Interface for a JDBC Connection

The JdbcBean.java class fetches a list of Employee objects.

Class Name: src/main/java/com/oracle/jdbc/samples/bean/JdbcBean.java

Github Location: JdbcBean.java

Steps to create JdbcBean.java:

  1. Declare the package for the class JdbcBean.java.
    package com.oracle.jdbc.samples.bean;
  2. Import Employee entity class as it contains the employee details.
    import com.oracle.jdbc.samples.entity.Employee;
  3. Declare an interface EmployeeBean class. Inside the EmployeeBean class, declare a method getEmployees() that returns a list of Employee objects. Similarly, you learn to declare the methods getEmployee(int), updateEmployee(int), getEmployeeByFn(String) and incrementSalary(int) for other functionalities in the next few chapters.
    
    public interface EmployeeBean {
        public List<Employee> getEmployees(); 
    }