EmpyoyeeManger_1.0, mindmanger16.0.159

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.