Web Service for CRUDE Operations of Database With JDBC …
Transcript of Web Service for CRUDE Operations of Database With JDBC …
Web Service for CRUDE Operations of Database
With JDBC and MS SQL Server
Summary:
Build a webpage that show a form and asks for input of a employee, once you
submit the form, it will store the employee details into the database using a stored procedure.
And display the list
Specification:
1. Create a company webpage where a new employee can a dd his/her information into
the Employee table by taking a new employee information with 9 Input Boxes for each
column Fname, MInit, Lname, ..., Dno as in Employee table schema With ADD button.
2. Write an Application Program that takes the new employee’s input from the webpage
and call a Stored Procedure SP_Insert_NewEmployee with the 9 input parameters.
3. Create the Stored Procedure SP_Insert_NewEmployee in your SQL Server that performs:
3-1. Takes 9 inputs to Insert a new employee tuple into the Employee table
3-2. Find all the projects that are controlled by the department that the new employee
works for.
3-3. Add all the project numbers with the new employee into Works_On table.
Set Up: Please Read the instruction on the Class Webpage
Design:
This is web application is built using MVC (Model view controller architecture). View is
used to display the output in a web page, controller is responsible for handling the input from
the used entered in the web page and store in the database. Used Eclipse tool to develop the
code and to run the web application installed Apache tomcat server.
EmployeeController.java is servlet, that will check for what view are you going to enter. That is,
if you are in submit mode, the servlet wil go submit log and insert the data into database and if
you are in delete mode, the servlet will perform delete action.
Following is the structure of the folders and packages in eclipse:
Implementation:
Starting point application starts at web.xml page, then it will go index.jsp page which
will redirect to EmployeeController.java file, there we have a logic to check initially which page
to display. Here we are displaying List of employees and list of works on page.
Screenshot:
The List of employees and works_on list will be displayed as shown below:
The above screenshot has a company logo, and list of employee, and below that table you can
see an add employee button, if you click on the add employee button, it will redirect to a add
employee page.
Add user logic is written above. Where wea re calling a procedure
‘dbo.SP_Insert_NewEmployee’
And also For each and every row there is column called action, it has a delete button. When you
click on delete button it will redirect to delete page where it will delete first
Above method, first we are deleting the data from works_on table based on ssn, and then
deleting the data from the employee table which is based on ssn.
Add New Employee Form will be as shown below
When you click the submit button, it will call the insert method which internally calls a stored
procedure.
Following is the stored procedure that is responsible to insert the employee details
The stored procedure is shown in folder
Showing the output screenshot after inserting of the employee into the database is done:
The updated record is shown in employee table as shown below
The updated record is shown in works_on table as shown below: