Java Reference
In-Depth Information
Once a new employee number has been received, the method inserts the record into the
database and a new employee number is returned to the caller; however, the final clause
will first make sure that the database connection has been closed. This is one of the many
techniques to ensure that resources are properly deallocated after the method completes its
task.
4.2.2.4.2 getEmpl(emplNo)
This method retrieves an employee record from the employees table of the database. A
unique employee number is a required input. If the record is found, it is returned to the
caller. Otherwise, an exception is thrown. Regardless, at this point, the database connection
is closed.
4.2.2.4.3 updateEmpl(empl)
This method updates a record with all values from the input record except the employee
number. A Boolean value of true or false is returned after the processing is completed. If
the record exists and the update completes successfully, a Boolean value of truth is returned.
Otherwise, the method returns false.
4.2.2.4.4 deleteEmpl(emplNo)
Similarly to other methods of this class, this method opens a database connection then
issues an SQL statement to complete the task. After a successful completion, an employee
record will be removed from the table and a Boolean value of truth is returned. Otherwise,
the method returns a value of false.
Overall, this class is relatively simple. It performs the most frequent operations on a resource
stored in the database. This class is kept simple because our focus is on the creation of Web Ser-
vices not database operations. When more complex business rules and multi-datasource data
access activities are involved, the fundamental concept of Web Services remains the same.
The main focus of Web Service is the interface - it must be robust and capable of evolving
over time.
In the next section, we briefly discuss how to test the data access object so that we can ensure
some basic quality assurance of the development team.
Search WWH ::




Custom Search