Database end-of-life big job Report

Source: Internet
Author: User
Tags mysql command line

Demand analysis

Modern society, cardiovascular disease has become a high incidence of chronic diseases in the elderly, a community doctor often need to be responsible for the diagnosis of multiple patients, if each patient has to visit frequently, will bring the doctor too much work pressure, also difficult to take into account all patients.

With the high popularity of information technology, we can use the Internet to solve problems, and make a software to realize:

L The physician is always in charge of the patient's blood pressure data and provides professional diagnostic advice to the patient.

l The patient uploads blood pressure data at any time and receives treatment advice from the doctor.

Overview design

1. Database

The data is stored in a MySQL database named Dochelper.

Database contains 4 tables: Doctor,patient,suggestion,pressure

Create the. sql file by importing it into the MySQL database.

Specific code see detailed design.

2. Java Program

As an interface for users to access the database, use swing to create a graphical interface to connect to the database using JDBC.

The software uses the MVC design pattern, divides into three levels:

L Model Layer entity: Contains 4 classes that correspond to 4 tables in a database.

L View Layer UI: Contains 7 interfaces inherited from JFrame for human-computer interaction.

L Business Logic Layer DAO: Contains 4 classes for connecting 4 classes of the model layer to the database, executing specific SQL statements as required

There is also a class dbutil dedicated to getting connections to the database.

Detailed design

1. Database SQL file:

Create Database Dochelper;

Use Dochelper;

CREATE TABLE Doctor (

doc_id smallint unsigned NOT NULL auto_increment,

Doc_name varchar () Not NULL unique key,

Doc_password varchar () NOT NULL,

Primary KEY (DOC_ID)

);

CREATE TABLE Patient (

pat_id smallint unsigned NOT NULL auto_increment,

Pat_name varchar () NOT NULL,

Pat_password varchar () NOT NULL,

Pat_doctor smallint unsigned,

Primary KEY (PAT_ID),

Foreign KEY (Pat_doctor) References Doctor (doc_id)

);

CREATE TABLE pressure (

pre_id smallint unsigned NOT NULL auto_increment,

Pre_high Int (ten) is not NULL,

Pre_low Int (ten) is not NULL,

Pre_date date,

Pre_pat smallint unsigned NOT NULL,

Primary KEY (PRE_ID),

Foreign KEY (Pre_pat) references patient (PAT_ID)

);

Create TABLE Suggestion (

sug_id smallint unsigned NOT NULL auto_increment,

Sug_sug text NOT NULL,

Sug_doc smallint unsigned NOT NULL,

Sug_pat smallint unsigned NOT NULL,

Sug_date date,

Primary KEY (SUG_ID),

Foreign KEY (Sug_pat) references patient (pat_id),

Foreign KEY (Sug_doc) References Doctor (doc_id)

);

2. Java Program

The source code is too large to show in this one by one, only to show the connection database code and UI interface:

Connect Database code:

Package dochelper.util;

import java.sql.*;

/**

* Connect to Database

* @author zhjl

*

*/

Public class Dbutil {

Static Final String jdbc_driver = "Com.mysql.jdbc.Driver";

Static Final String Db_url = "Jdbc:mysql://localhost/dochelper";

Static Final String USER = "root";

Static Final String PASS = "123456";

/**

* Get database connection

* @return

* @throws Exception

*/

Public Connection getconnection () throws exception{

Class. forname (jdbc_driver);

Connection conn = DriverManager. getconnection (db_url, USER, PASS);

return Conn;

}

/**

* Close Connection

* @param Conn

* @throws Exception

*/

Public void closeconnection (Connection conn) throws exception{

if (conn!=null)

Conn.close ();

}

}

Login interface:

Doctor Registration Screen:

Patient Registration Interface:

Doctor's side:

Doctor-side Account Setup Interface:

Patient side:

Patient-Side Account Setup Interface:

User Manuals

How are you doing! Welcome to Dr. Green Leaf, a member of the cardiovascular health community. We are committed to the easy communication of physicians and patients, and provide the best solution for solving cardiovascular health counseling problems.

The interface of software is divided into three parts: main interface, doctor-side, patient-side. See the help you need, depending on the situation.

main interface (direct entry after opening the program):

Login: Enter an existing user name and password, select "Doctor" or "Patient", click "Login"

Sign up: Create a new account, select "Doctor" or "Patient" status, click "Register", enter the registration information in the new interface and confirm.

Doctor side (enter after successful login from the main interface):

View patient's blood pressure data: Select patients in the upper left table to view their blood pressure data

Advice to patients: Select the patient object to suggest in the upper left table, enter a suggestion in the input box, and click the Add Suggestion button.

View suggestions: Select a patient in the upper left table to see its diagnostic history in the table below.

Modify suggestions: Select the suggestions you want to modify in the table below, enter the new content in the input box, click the "Modify Suggestions" button

Delete Suggestion: Select the suggestion you want to delete in the table below, click the Delete Suggestion button

Modify account information: Click the "Account Settings" button to jump to the Account Settings screen. After verifying that the old password is successful, you can enter a new user name and password and confirm.

Return: Log out and return to the main interface.

Patient Side (enter after successful login from the main interface):

View your own blood pressure data: see the blood pressure data display box.

Add blood pressure data: Fill in the "systolic pressure" and "diastolic pressure" and click Add.

Check out the doctor's advice: see the Doctor's suggestion box.

Modify account information: Click the "Account Settings" button to jump to the Account Settings screen. After verifying that the old password is successful, you can enter a new user name and password and confirm.

Modify Doctor Association: Click the "Account Settings" button to jump to the Account Settings screen. In the list of doctors, select the doctor and click "Associate" to complete the association.

Return: Log out and return to the main interface.

Reflection Summary (Development log)

Looking back at the three months of making the database big job, it was a mixed journey for me.

The first time I heard the requirements of the database experiment, in fact, I was ignorant force: actually to use Java, and I even did not write C, for the object-oriented Java is basically ignorant. The first class with Swt/jface development GUI, completely listen to foggy, although will use Windowbuilder drag a JButton, JLabel up, but the behind the code is ignorant.

There is no way, can only learn Java from the beginning, followed by the online Mooc tutorial and "Core Java", took a full two weeks to master the basic knowledge of JSE. The process is very hard but also a sense of accomplishment, and slowly realized the power of object-oriented programming: the use of objects to store data, with class encapsulation code, to maximize the structure of the program modular, the large task of decomposition into a small task. It is also realized that the writing process is like building a house, the foundation (frame) is very important, good program is often behind the thoroughly tempered design pattern, to work with the MVC design pattern For example, the program is divided into solid layer, view layer, database connection layer, design only consider a level of things, development efficiency greatly improved, Code simplicity and maintainability are much better.

Learning to use SWT is really depressing, on the one hand, the graphical interface is not Java's strengths, swing such development tools have been basically eliminated by the Times, on the other hand swing control a wide variety of inheritance relationships complex, sometimes in order to find a method, it takes a lot of time to consult the API documentation, The first use of the efficiency is not very high, but it is ok after cooked. As this semester just in the study of general course "plane production basis", the use of vector software CorelDRAW to the GUI made a logo, indeed better than the swing of the original interface look a lot. From the feedback of friends, the most important thing is the UI ah, after all, a bad interface software is difficult to let people have the impulse to understand its rich and powerful features.

The next database setup is not too much time, using a high level of integration of the development environment such as PowerDesigner or SQL Server, MySQL Workbench, etc. can be completed in a short time, the time is mainly spent on the design table. For the sake of practicing SQL statements and support for open source, I chose to write the code created in the database with Notepad and use the MySQL command line to query, modify, and so on.

Next is the most critical place: connect to the database. The example given by the TA uses the spring framework of the jdbctemplate, although has learned jse, but still can not understand what is written, nor read. xml files. It takes some time to learn the spring framework, and now it's not web development, and it's hard to use it later, so we chose the more classic and simple jdbc. Using the Dbutil class to store database connections, the DAO class is responsible for submitting the appropriate SQL statements to the database according to different query requirements.

Finally, frankly speaking, I think the requirements of the experimental course is a bit too high, seems to deviate from the core of the database course, for which it occupies a lot of my spare time, but this is my first time to write large projects, the first contact with object-oriented programming language, to some extent it has stimulated my potential, I am excited by the sense of accomplishment that comes with difficulty. Even after I finished my homework I tried to use swing to write a tank battle program as an extra job as a data structure, and I also plan to get into the JEE and SSM framework during the summer vacation, and in the foreseeable future, Java will be the most frequently used language for me.

And it all started, but it was amazing to take a class called database theory.

Database end-of-life big job Report

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.