EmpyoyeeManger_1.0, mindmanger16.0.159
Overall Structure
First, create a database named "employee ".
Create database employee;
Create a table under the database.
CREATE TABLE t_emp( id BIGINT PRIMARY KEY AUTO_INCREMENT, NAME VARCHAR(50) UNIQUE, salary DOUBLE , age INT);
Then, contact the project and database, and then operate the database (add, delete, modify, and query)
After reading the previous project, everyone should be troubled by the need to reconnect to the database for each operation, and the code is highly repetitive, We will encapsulate the same code into a tool class (utils)
The Code is as follows:
The jar package must be placed under lib.
Create the Emloyee object class below. The attributes of this object class should correspond to the fields in the t_emp table created.
The Code is as follows:
This type of property is private, and each property has the set and get methods. The Java class is called JavaBean.
Next is an interface
Code
Implement this interface
Code
Add
Delete
FindAll
FindById
Update
Next is the homepage (displaying all employees, implemented using servlet)
The following is displayed in the browser:
Click Modify link to jump to another servlet and pass the id
Code
Code
The modification function is implemented. delete is implemented below.
Code
Delete to implement (this code looks too small)
Then there is the last function (and it's almost over ........)
When you click addEmployee
Export to addemp.html
Code
Code
Web. xml