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:
- Declare the package for the class
JdbcBean.java
.package com.oracle.jdbc.samples.bean;
- Import
Employee
entity class as it contains the employee details.import com.oracle.jdbc.samples.entity.Employee;
- Declare an interface
EmployeeBean
class. Inside theEmployeeBean
class, declare a methodgetEmployees()
that returns a list ofEmployee
objects. Similarly, you learn to declare the methodsgetEmployee(int)
,updateEmployee(int)
,getEmployeeByFn(String)
andincrementSalary(int)
for other functionalities in the next few chapters.public interface EmployeeBean { public List<Employee> getEmployees(); }