├── README.md
├── design
├── .idea
│ ├── libraries
│ │ ├── json_lib_1_1_jdk13.xml
│ │ └── json_lib_1_1_jdk13__2_.xml
│ ├── misc.xml
│ ├── modules.xml
│ ├── uiDesigner.xml
│ └── workspace.xml
├── 142宿舍
│ ├── 1607094128 解奕鹏.zip
│ ├── 1607094131 潘森.zip
│ ├── 1607094132 赵越.zip
│ └── 1607094133 王艺凡.zip
├── design.iml
├── design.sql
├── out
│ └── production
│ │ └── design
│ │ ├── MainTest.class
│ │ ├── bean
│ │ ├── City.class
│ │ ├── Forecast.class
│ │ └── Weather.class
│ │ ├── frame
│ │ ├── Landing$1.class
│ │ ├── Landing$2.class
│ │ ├── Landing$3.class
│ │ ├── Landing.class
│ │ ├── Login$1.class
│ │ ├── Login$2.class
│ │ ├── Login.class
│ │ ├── Main$1.class
│ │ ├── Main$2.class
│ │ ├── Main$3.class
│ │ ├── Main.class
│ │ ├── Manage$1.class
│ │ ├── Manage$10.class
│ │ ├── Manage$11.class
│ │ ├── Manage$12.class
│ │ ├── Manage$13.class
│ │ ├── Manage$14.class
│ │ ├── Manage$15.class
│ │ ├── Manage$16.class
│ │ ├── Manage$17.class
│ │ ├── Manage$18.class
│ │ ├── Manage$2.class
│ │ ├── Manage$3.class
│ │ ├── Manage$4.class
│ │ ├── Manage$5.class
│ │ ├── Manage$6.class
│ │ ├── Manage$7.class
│ │ ├── Manage$8.class
│ │ ├── Manage$9.class
│ │ ├── Manage.class
│ │ └── icon
│ │ │ ├── Loading.png
│ │ │ ├── cloudy.png
│ │ │ ├── cloudyBig.png
│ │ │ ├── login.png
│ │ │ ├── main.png
│ │ │ ├── manage.png
│ │ │ ├── rain.png
│ │ │ ├── rainBig.png
│ │ │ ├── snow.png
│ │ │ ├── snowBig.png
│ │ │ ├── sunny.png
│ │ │ └── sunnyBig.png
│ │ ├── reference
│ │ ├── Lognin$1.class
│ │ ├── Lognin$2.class
│ │ └── Lognin.class
│ │ ├── test.class
│ │ ├── tools
│ │ ├── HttpRequest.class
│ │ ├── MineDialog$1.class
│ │ └── MineDialog.class
│ │ └── web
│ │ ├── beijing.json
│ │ ├── city.json
│ │ └── taiyuan.json
└── src
│ ├── MainTest.java
│ ├── bean
│ ├── City.java
│ ├── Forecast.java
│ └── Weather.java
│ ├── frame
│ ├── Landing.java
│ ├── Login.java
│ ├── Main.java
│ ├── Manage.java
│ └── icon
│ │ ├── Loading.png
│ │ ├── cloudy.png
│ │ ├── cloudyBig.png
│ │ ├── login.png
│ │ ├── main.png
│ │ ├── manage.png
│ │ ├── rain.png
│ │ ├── rainBig.png
│ │ ├── snow.png
│ │ ├── snowBig.png
│ │ ├── sunny.png
│ │ └── sunnyBig.png
│ ├── reference
│ └── Lognin.java
│ ├── test.java
│ ├── tools
│ ├── HttpRequest.java
│ └── MineDialog.java
│ └── web
│ ├── beijing.json
│ ├── city.json
│ └── taiyuan.json
├── experiment_four.sql
├── experiment_one.sql
├── experiment_three.sql
├── experiment_two.sql
├── jar
├── .idea
│ ├── .name
│ ├── artifacts
│ │ └── curd_jdbc_xieyipeng.xml
│ ├── libraries
│ │ └── curd_jdbc_xieyipeng.xml
│ ├── misc.xml
│ ├── modules.xml
│ ├── uiDesigner.xml
│ ├── vcs.xml
│ └── workspace.xml
├── Database.iml
├── out
│ └── production
│ │ └── Database
│ │ ├── 1.png
│ │ ├── libs
│ │ ├── curd_jdbc_xieyipeng.jar
│ │ └── mssql-jdbc-7.0.0.jre8.jar
│ │ └── test.class
└── src
│ ├── 1.png
│ ├── SocketTest.java
│ └── libs
│ ├── curd_jdbc_xieyipeng.jar
│ └── mssql-jdbc-7.0.0.jre8.jar
└── 课本
├── 第一章-绪论.md
├── 第七章-数据库设计.md
├── 第三章关系数据库标准语言SQL.md
├── 第二章-关系数据库.md
├── 第五章-数据库完整性.md
├── 第六章-关系数据理论.md
├── 第十一章-并发控制.md
├── 第十章数据库恢复技术.md
└── 第四章-数据库安全性.md
/README.md:
--------------------------------------------------------------------------------
1 | # DataBase
2 | 数据库系统概论
3 |
--------------------------------------------------------------------------------
/design/.idea/libraries/json_lib_1_1_jdk13.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/design/.idea/libraries/json_lib_1_1_jdk13__2_.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/design/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/design/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/design/.idea/uiDesigner.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | -
6 |
7 |
8 | -
9 |
10 |
11 | -
12 |
13 |
14 | -
15 |
16 |
17 | -
18 |
19 |
20 |
21 |
22 |
23 | -
24 |
25 |
26 |
27 |
28 |
29 | -
30 |
31 |
32 |
33 |
34 |
35 | -
36 |
37 |
38 |
39 |
40 |
41 | -
42 |
43 |
44 |
45 |
46 | -
47 |
48 |
49 |
50 |
51 | -
52 |
53 |
54 |
55 |
56 | -
57 |
58 |
59 |
60 |
61 | -
62 |
63 |
64 |
65 |
66 | -
67 |
68 |
69 |
70 |
71 | -
72 |
73 |
74 | -
75 |
76 |
77 |
78 |
79 | -
80 |
81 |
82 |
83 |
84 | -
85 |
86 |
87 |
88 |
89 | -
90 |
91 |
92 |
93 |
94 | -
95 |
96 |
97 |
98 |
99 | -
100 |
101 |
102 | -
103 |
104 |
105 | -
106 |
107 |
108 | -
109 |
110 |
111 | -
112 |
113 |
114 |
115 |
116 | -
117 |
118 |
119 | -
120 |
121 |
122 |
123 |
124 |
--------------------------------------------------------------------------------
/design/142宿舍/1607094128 解奕鹏.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/142宿舍/1607094128 解奕鹏.zip
--------------------------------------------------------------------------------
/design/142宿舍/1607094131 潘森.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/142宿舍/1607094131 潘森.zip
--------------------------------------------------------------------------------
/design/142宿舍/1607094132 赵越.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/142宿舍/1607094132 赵越.zip
--------------------------------------------------------------------------------
/design/142宿舍/1607094133 王艺凡.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/142宿舍/1607094133 王艺凡.zip
--------------------------------------------------------------------------------
/design/design.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/design/design.sql:
--------------------------------------------------------------------------------
1 | create table city(
2 | city_name char(20) primary key,
3 | city_regional char(10) not null,
4 | );
5 |
6 | create table weather(
7 | weather_date char(8),
8 | city char(20),
9 | shidu char(5),
10 | quality char(5),
11 | wendu char(5),
12 | sunrise char(5),
13 | sunset char(5),
14 | weather_type char(20),
15 | weather_week char(20),
16 | high char(20),
17 | low char(20),
18 | primary key (weather_date,city),
19 | foreign key (city)references city(city_name)
20 | );
21 |
22 | create table management(
23 | userName char(20) primary key,
24 | wordPass char(20)
25 | )
26 |
27 | create table ordinaryUser(
28 | userName char(20) primary key,
29 | wordPass char(20)
30 | )
--------------------------------------------------------------------------------
/design/out/production/design/MainTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/MainTest.class
--------------------------------------------------------------------------------
/design/out/production/design/bean/City.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/bean/City.class
--------------------------------------------------------------------------------
/design/out/production/design/bean/Forecast.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/bean/Forecast.class
--------------------------------------------------------------------------------
/design/out/production/design/bean/Weather.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/bean/Weather.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Landing$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Landing$1.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Landing$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Landing$2.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Landing$3.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Landing$3.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Landing.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Landing.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Login$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Login$1.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Login$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Login$2.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Login.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Login.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Main$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Main$1.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Main$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Main$2.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Main$3.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Main$3.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Main.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Main.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Manage$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Manage$1.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Manage$10.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Manage$10.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Manage$11.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Manage$11.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Manage$12.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Manage$12.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Manage$13.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Manage$13.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Manage$14.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Manage$14.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Manage$15.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Manage$15.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Manage$16.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Manage$16.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Manage$17.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Manage$17.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Manage$18.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Manage$18.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Manage$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Manage$2.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Manage$3.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Manage$3.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Manage$4.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Manage$4.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Manage$5.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Manage$5.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Manage$6.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Manage$6.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Manage$7.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Manage$7.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Manage$8.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Manage$8.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Manage$9.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Manage$9.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/Manage.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/Manage.class
--------------------------------------------------------------------------------
/design/out/production/design/frame/icon/Loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/icon/Loading.png
--------------------------------------------------------------------------------
/design/out/production/design/frame/icon/cloudy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/icon/cloudy.png
--------------------------------------------------------------------------------
/design/out/production/design/frame/icon/cloudyBig.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/icon/cloudyBig.png
--------------------------------------------------------------------------------
/design/out/production/design/frame/icon/login.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/icon/login.png
--------------------------------------------------------------------------------
/design/out/production/design/frame/icon/main.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/icon/main.png
--------------------------------------------------------------------------------
/design/out/production/design/frame/icon/manage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/icon/manage.png
--------------------------------------------------------------------------------
/design/out/production/design/frame/icon/rain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/icon/rain.png
--------------------------------------------------------------------------------
/design/out/production/design/frame/icon/rainBig.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/icon/rainBig.png
--------------------------------------------------------------------------------
/design/out/production/design/frame/icon/snow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/icon/snow.png
--------------------------------------------------------------------------------
/design/out/production/design/frame/icon/snowBig.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/icon/snowBig.png
--------------------------------------------------------------------------------
/design/out/production/design/frame/icon/sunny.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/icon/sunny.png
--------------------------------------------------------------------------------
/design/out/production/design/frame/icon/sunnyBig.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/frame/icon/sunnyBig.png
--------------------------------------------------------------------------------
/design/out/production/design/reference/Lognin$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/reference/Lognin$1.class
--------------------------------------------------------------------------------
/design/out/production/design/reference/Lognin$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/reference/Lognin$2.class
--------------------------------------------------------------------------------
/design/out/production/design/reference/Lognin.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/reference/Lognin.class
--------------------------------------------------------------------------------
/design/out/production/design/test.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/test.class
--------------------------------------------------------------------------------
/design/out/production/design/tools/HttpRequest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/tools/HttpRequest.class
--------------------------------------------------------------------------------
/design/out/production/design/tools/MineDialog$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/tools/MineDialog$1.class
--------------------------------------------------------------------------------
/design/out/production/design/tools/MineDialog.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/out/production/design/tools/MineDialog.class
--------------------------------------------------------------------------------
/design/out/production/design/web/beijing.json:
--------------------------------------------------------------------------------
1 | {
2 | "date":"20180618",
3 | "message":"Success !",
4 | "status":200,
5 | "city":"北京",
6 | "count":17,
7 | "data":{
8 | "shidu":"80%",
9 | "pm25":57.0,
10 | "pm10":64.0,
11 | "quality":"良",
12 | "wendu":"22",
13 | "ganmao":"极少数敏感人群应减少户外活动",
14 | "yesterday":{
15 | "date":"17日星期日",
16 | "sunrise":"04:45",
17 | "high":"高温 28.0℃",
18 | "low":"低温 20.0℃",
19 | "sunset":"19:45",
20 | "aqi":50.0,
21 | "fx":"南风",
22 | "fl":"<3级",
23 | "type":"阵雨",
24 | "notice":"阵雨来袭,出门记得带伞"
25 | },
26 | "forecast":[
27 | {
28 | "date":"18日星期一",
29 | "sunrise":"04:45",
30 | "high":"高温 30.0℃",
31 | "low":"低温 21.0℃",
32 | "sunset":"19:45",
33 | "aqi":95.0,
34 | "fx":"西南风",
35 | "fl":"<3级",
36 | "type":"雷阵雨",
37 | "notice":"带好雨具,别在树下躲雨"
38 | },
39 | {
40 | "date":"19日星期二",
41 | "sunrise":"04:45",
42 | "high":"高温 32.0℃",
43 | "low":"低温 21.0℃",
44 | "sunset":"19:45",
45 | "aqi":59.0,
46 | "fx":"东北风",
47 | "fl":"<3级",
48 | "type":"多云",
49 | "notice":"阴晴之间,谨防紫外线侵扰"
50 | },
51 | {
52 | "date":"20日星期三",
53 | "sunrise":"04:46",
54 | "high":"高温 34.0℃",
55 | "low":"低温 22.0℃",
56 | "sunset":"19:46",
57 | "aqi":52.0,
58 | "fx":"北风",
59 | "fl":"<3级",
60 | "type":"晴",
61 | "notice":"愿你拥有比阳光明媚的心情"
62 | },
63 | {
64 | "date":"21日星期四",
65 | "sunrise":"04:46",
66 | "high":"高温 34.0℃",
67 | "low":"低温 23.0℃",
68 | "sunset":"19:46",
69 | "aqi":81.0,
70 | "fx":"南风",
71 | "fl":"<3级",
72 | "type":"多云",
73 | "notice":"阴晴之间,谨防紫外线侵扰"
74 | },
75 | {
76 | "date":"22日星期五",
77 | "sunrise":"04:46",
78 | "high":"高温 31.0℃",
79 | "low":"低温 21.0℃",
80 | "sunset":"19:46",
81 | "aqi":94.0,
82 | "fx":"东南风",
83 | "fl":"<3级",
84 | "type":"多云",
85 | "notice":"阴晴之间,谨防紫外线侵扰"
86 | }
87 | ]
88 | }
89 | }
--------------------------------------------------------------------------------
/design/out/production/design/web/taiyuan.json:
--------------------------------------------------------------------------------
1 | {
2 | "date": "20180622",
3 | "message": "Success !",
4 | "status": 200,
5 | "city": "太原",
6 | "count": 2,
7 | "data": {
8 | "shidu": "78%",
9 | "pm25": 29.0,
10 | "pm10": 71.0,
11 | "quality": "良",
12 | "wendu": "18",
13 | "ganmao": "极少数敏感人群应减少户外活动",
14 | "yesterday": {
15 | "date": "21日星期四",
16 | "sunrise": "05:07",
17 | "high": "高温 27.0℃",
18 | "low": "低温 16.0℃",
19 | "sunset": "19:55",
20 | "aqi": 107.0,
21 | "fx": "东风",
22 | "fl": "<3级",
23 | "type": "中雨",
24 | "notice": "记得随身携带雨伞哦"
25 | },
26 | "forecast": [
27 | {
28 | "date": "22日星期五",
29 | "sunrise": "05:08",
30 | "high": "高温 31.0℃",
31 | "low": "低温 18.0℃",
32 | "sunset": "19:55",
33 | "aqi": 64.0,
34 | "fx": "南风",
35 | "fl": "<3级",
36 | "type": "多云",
37 | "notice": "阴晴之间,谨防紫外线侵扰"
38 | },
39 | {
40 | "date": "23日星期六",
41 | "sunrise": "05:08",
42 | "high": "高温 34.0℃",
43 | "low": "低温 20.0℃",
44 | "sunset": "19:55",
45 | "aqi": 73.0,
46 | "fx": "东风",
47 | "fl": "<3级",
48 | "type": "晴",
49 | "notice": "愿你拥有比阳光明媚的心情"
50 | },
51 | {
52 | "date": "24日星期日",
53 | "sunrise": "05:08",
54 | "high": "高温 33.0℃",
55 | "low": "低温 19.0℃",
56 | "sunset": "19:56",
57 | "aqi": 69.0,
58 | "fx": "南风",
59 | "fl": "<3级",
60 | "type": "多云",
61 | "notice": "阴晴之间,谨防紫外线侵扰"
62 | },
63 | {
64 | "date": "25日星期一",
65 | "sunrise": "05:08",
66 | "high": "高温 30.0℃",
67 | "low": "低温 20.0℃",
68 | "sunset": "19:56",
69 | "aqi": 67.0,
70 | "fx": "东北风",
71 | "fl": "<3级",
72 | "type": "小雨",
73 | "notice": "雨虽小,注意保暖别感冒"
74 | },
75 | {
76 | "date": "26日星期二",
77 | "sunrise": "05:09",
78 | "high": "高温 27.0℃",
79 | "low": "低温 17.0℃",
80 | "sunset": "19:56",
81 | "aqi": 60.0,
82 | "fx": "东北风",
83 | "fl": "<3级",
84 | "type": "多云",
85 | "notice": "阴晴之间,谨防紫外线侵扰"
86 | }
87 | ]
88 | }
89 | }
--------------------------------------------------------------------------------
/design/src/MainTest.java:
--------------------------------------------------------------------------------
1 | import bean.City;
2 | import bean.Forecast;
3 | import bean.Weather;
4 | import com.google.gson.JsonArray;
5 | import com.google.gson.JsonObject;
6 | import com.google.gson.JsonParser;
7 |
8 | import tools.HttpRequest;
9 |
10 | import java.sql.*;
11 | import java.util.ArrayList;
12 | import java.util.List;
13 | import java.util.Scanner;
14 |
15 | import static bean.City.getCity;
16 | import static bean.City.getCode;
17 |
18 | // public static final String WEATHER_XML_URL = "https://www.sojson.com/open/api/weather/xml.shtml?city=";
19 |
20 | public class MainTest {
21 |
22 | private static final String WEATHER_JSON_URL = "https://www.sojson.com/open/api/weather/json.shtml?city=";
23 | private static final String DBURL = "jdbc:sqlserver://localhost:1433;databaseName=design";
24 | private static final String userName = "xieyipeng";
25 | private static final String userPwd = "123456";
26 |
27 | public static void main(String[] args) {
28 | int user = initUser();
29 | String city = joinCity();//输入城市名称
30 | }
31 |
32 | private static int initUser() {
33 | System.out.println("1:系统管理员");
34 | System.out.println("2:气象部门工作人员");
35 | System.out.println("3:普通用户");
36 | System.out.println("4:统计人员");
37 | System.out.println("** 请选择登陆方式(输入数字) **");
38 | int user = 0;
39 | boolean in = true;
40 | while (in) {
41 | Scanner scanner = new Scanner(System.in);
42 | user = scanner.nextInt();
43 | if (user == 1 | user == 2 | user == 3 | user == 4) {
44 | in = false;
45 | } else {
46 | System.out.println("输入格式不正确,请重新输入");
47 | }
48 | }
49 | return user;
50 | }
51 |
52 | /**
53 | * 向数据库中添加城市信息
54 | */
55 | private static void initCity(int user) {
56 | Connection connection = null;
57 | Statement statement = null;
58 | ResultSet resultSet = null;
59 | if (user==3|user==4){
60 | return;
61 | }
62 | try {
63 | connection = DriverManager.getConnection(DBURL, userName, userPwd);
64 | System.out.println("添加城市信息,数据库连接成功。");
65 | statement = connection.createStatement();
66 | String beijing = "'北京'";
67 | String nextOrNot = "select *" +
68 | "FROM city " +
69 | "WHERE city.city_name=" + beijing;
70 | resultSet = statement.executeQuery(nextOrNot);
71 | if (resultSet.next()) {
72 | System.out.println("城市信息已经添加完毕,不能重复添加。");
73 | return;
74 | } else {
75 | List cityCode = City.separate();
76 | List city = getCity(cityCode);
77 | List code = getCode(cityCode);
78 | for (int i = 0; i < city.size(); i++) {
79 | String SQL = "INSERT INTO city(" +
80 | "city_name,city_regional)" +
81 | "VALUES (" + city.get(i) + "," + code.get(i) +
82 | ")";
83 | statement.executeUpdate(SQL);
84 | int a = i + 1;
85 | System.out.println("第" + a + "个城市信息添加成功!");
86 | }
87 | }
88 | connection.close();
89 | } catch (SQLException e) {
90 | e.printStackTrace();
91 | } finally {
92 | if (resultSet != null) {
93 | try {
94 | resultSet.close();
95 | } catch (SQLException e) {
96 | e.printStackTrace();
97 | }
98 | }
99 | if (statement != null) {
100 | try {
101 | statement.close();
102 | } catch (SQLException e) {
103 | e.printStackTrace();
104 | }
105 | }
106 | if (connection != null) {
107 | try {
108 | connection.close();
109 | } catch (SQLException e) {
110 | e.printStackTrace();
111 | }
112 | }
113 | }
114 | }
115 |
116 | /**
117 | * 向数据库中添加天气数据
118 | *
119 | * @param weather weather
120 | * @param forecasts forecasts
121 | */
122 | private static void addData(String city, Weather weather, List forecasts) {
123 | Connection connection = null;
124 | Statement statement = null;
125 | // ResultSet resultSet = null;
126 | try {
127 | connection = DriverManager.getConnection(DBURL, userName, userPwd);
128 | System.out.println("添加天气数据,数据库连接成功。");
129 | statement = connection.createStatement();
130 | if (city != null) {
131 | city = "\'" + city + "\'";
132 | String SQL = "INSERT INTO weather(weather_date,city,shidu,pm25,quality,wendu,sunrise,sunset,weather_type,notice,weather_week,high,low)" +
133 | "VALUES (" + weather.getWeatherDate() + "," + city + "," + weather.getShidu() + "," +
134 | weather.getQuality() + "," + weather.getWendu() + "," +
135 | forecasts.get(0).getSunrise() + "," + forecasts.get(0).getSunset() + "," +
136 | forecasts.get(0).getType() + "," + forecasts.get(0).getNotice() + "," +
137 | forecasts.get(0).getWeek() + "," + forecasts.get(0).getHigh() + "," + forecasts.get(0).getLow() + ")";
138 | statement.executeUpdate(SQL);
139 | System.out.println("添加天气数据成功。");
140 | } else {
141 | System.out.println("city = null");
142 | }
143 | connection.close();
144 | } catch (SQLException e) {
145 | e.printStackTrace();
146 | } finally {
147 | if (statement != null) try {
148 | statement.close();
149 | } catch (SQLException e) {
150 | e.printStackTrace();
151 | }
152 | if (connection != null) try {
153 | connection.close();
154 | } catch (SQLException e) {
155 | e.printStackTrace();
156 | }
157 | }
158 | }
159 |
160 | /**
161 | * 输入城市
162 | *
163 | * @return 未解析的json
164 | */
165 | private static String joinCity() {
166 | System.out.println("输入城市名称:");
167 | Scanner scanner = new Scanner(System.in);
168 | String city = scanner.next();
169 | if (!City.CITY_CODE.contains(city)) {
170 | System.out.println("请输入正确的城市名称。");
171 | return null;
172 | } else {
173 | return city;
174 | }
175 | }
176 | }
177 |
178 |
--------------------------------------------------------------------------------
/design/src/bean/City.java:
--------------------------------------------------------------------------------
1 | package bean;
2 |
3 | import com.google.gson.JsonArray;
4 | import com.google.gson.JsonObject;
5 | import com.google.gson.JsonParser;
6 |
7 | import java.io.*;
8 | import java.util.ArrayList;
9 | import java.util.List;
10 | import java.util.regex.Matcher;
11 | import java.util.regex.Pattern;
12 |
13 | public class City {
14 |
15 | public static final String CITY_CODE = "北京:101010100北京朝阳:101010300顺义:101010400怀柔:101010500通州:101010600昌平:101010700延庆:101010800丰台:101010900石景山:101011000大兴:101011100房山:101011200密云:101011300门头沟:101011400平谷:101011500八达岭:101011600佛爷顶:101011700汤河口:101011800密云上甸子:101011900斋堂:101012000霞云岭:101012100北京城区:101012200海淀:101010200天津:101030100宝坻:101030300东丽:101030400西青:101030500北辰:101030600蓟县:101031400汉沽:101030800静海:101030900津南:101031000塘沽:101031100大港:101031200武清:101030200宁河:101030700上海:101020100宝山:101020300嘉定:101020500南汇:101020600浦东:101021300青浦:101020800松江:101020900奉贤:101021000崇明:101021100徐家汇:101021200闵行:101020200金山:101020700石家庄:101090101张家口:101090301承德:101090402唐山:101090501秦皇岛:101091101沧州:101090701衡水:101090801邢台:101090901邯郸:101091001保定:101090201廊坊:101090601郑州:101180101新乡:101180301许昌:101180401平顶山:101180501信阳:101180601南阳:101180701开封:101180801洛阳:101180901商丘:101181001焦作:101181101鹤壁:101181201濮阳:101181301周口:101181401漯河:101181501驻马店:101181601三门峡:101181701济源:101181801安阳:101180201合肥:101220101芜湖:101220301淮南:101220401马鞍山:101220501安庆:101220601宿州:101220701阜阳:101220801亳州:101220901黄山:101221001滁州:101221101淮北:101221201铜陵:101221301宣城:101221401六安:101221501巢湖:101221601池州:101221701蚌埠:101220201杭州:101210101舟山:101211101湖州:101210201嘉兴:101210301金华:101210901绍兴:101210501台州:101210601温州:101210701丽水:101210801衢州:101211001宁波:101210401重庆:101040100合川:101040300南川:101040400江津:101040500万盛:101040600渝北:101040700北碚:101040800巴南:101040900长寿:101041000黔江:101041100万州天城:101041200万州龙宝:101041300涪陵:101041400开县:101041500城口:101041600云阳:101041700巫溪:101041800奉节:101041900巫山:101042000潼南:101042100垫江:101042200梁平:101042300忠县:101042400石柱:101042500大足:101042600荣昌:101042700铜梁:101042800璧山:101042900丰都:101043000武隆:101043100彭水:101043200綦江:101043300酉阳:101043400秀山:101043600沙坪坝:101043700永川:101040200福州:101230101泉州:101230501漳州:101230601龙岩:101230701晋江:101230509南平:101230901厦门:101230201宁德:101230301莆田:101230401三明:101230801兰州:101160101平凉:101160301庆阳:101160401武威:101160501金昌:101160601嘉峪关:101161401酒泉:101160801天水:101160901武都:101161001临夏:101161101合作:101161201白银:101161301定西:101160201张掖:101160701广州:101280101惠州:101280301梅州:101280401汕头:101280501深圳:101280601珠海:101280701佛山:101280800肇庆:101280901湛江:101281001江门:101281101河源:101281201清远:101281301云浮:101281401潮州:101281501东莞:101281601中山:101281701阳江:101281801揭阳:101281901茂名:101282001汕尾:101282101韶关:101280201南宁:101300101柳州:101300301来宾:101300401桂林:101300501梧州:101300601防城港:101301401贵港:101300801玉林:101300901百色:101301001钦州:101301101河池:101301201北海:101301301崇左:101300201贺州:101300701贵阳:101260101安顺:101260301都匀:101260401兴义:101260906铜仁:101260601毕节:101260701六盘水:101260801遵义:101260201凯里:101260501昆明:101290101红河:101290301文山:101290601玉溪:101290701楚雄:101290801普洱:101290901昭通:101291001临沧:101291101怒江:101291201香格里拉:101291301丽江:101291401德宏:101291501景洪:101291601大理:101290201曲靖:101290401保山:101290501呼和浩特:101080101乌海:101080301集宁:101080401通辽:101080501阿拉善左旗:101081201鄂尔多斯:101080701临河:101080801锡林浩特:101080901呼伦贝尔:101081000乌兰浩特:101081101包头:101080201赤峰:101080601南昌:101240101上饶:101240301抚州:101240401宜春:101240501鹰潭:101241101赣州:101240701景德镇:101240801萍乡:101240901新余:101241001九江:101240201吉安:101240601武汉:101200101黄冈:101200501荆州:101200801宜昌:101200901恩施:101201001十堰:101201101神农架:101201201随州:101201301荆门:101201401天门:101201501仙桃:101201601潜江:101201701襄樊:101200201鄂州:101200301孝感:101200401黄石:101200601咸宁:101200701成都:101270101自贡:101270301绵阳:101270401南充:101270501达州:101270601遂宁:101270701广安:101270801巴中:101270901泸州:101271001宜宾:101271101内江:101271201资阳:101271301乐山:101271401眉山:101271501凉山:101271601雅安:101271701甘孜:101271801阿坝:101271901德阳:101272001广元:101272101攀枝花:101270201银川:101170101中卫:101170501固原:101170401石嘴山:101170201吴忠:101170301西宁:101150101黄南:101150301海北:101150801果洛:101150501玉树:101150601海西:101150701海东:101150201海南:101150401济南:101120101潍坊:101120601临沂:101120901菏泽:101121001滨州:101121101东营:101121201威海:101121301枣庄:101121401日照:101121501莱芜:101121601聊城:101121701青岛:101120201淄博:101120301德州:101120401烟台:101120501济宁:101120701泰安:101120801西安:101110101延安:101110300榆林:101110401铜川:101111001商洛:101110601安康:101110701汉中:101110801宝鸡:101110901咸阳:101110200渭南:101110501太原:101100101临汾:101100701运城:101100801朔州:101100901忻州:101101001长治:101100501大同:101100201阳泉:101100301晋中:101100401晋城:101100601吕梁:101101100乌鲁木齐:101130101石河子:101130301昌吉:101130401吐鲁番:101130501库尔勒:101130601阿拉尔:101130701阿克苏:101130801喀什:101130901伊宁:101131001塔城:101131101哈密:101131201和田:101131301阿勒泰:101131401阿图什:101131501博乐:101131601克拉玛依:101130201拉萨:101140101山南:101140301阿里:101140701昌都:101140501那曲:101140601日喀则:101140201林芝:101140401台北县:101340101高雄:101340201台中:101340401海口:101310101三亚:101310201东方:101310202临高:101310203澄迈:101310204儋州:101310205昌江:101310206白沙:101310207琼中:101310208定安:101310209屯昌:101310210琼海:101310211文昌:101310212保亭:101310214万宁:101310215陵水:101310216西沙:101310217南沙岛:101310220乐东:101310221五指山:101310222琼山:101310102长沙:101250101株洲:101250301衡阳:101250401郴州:101250501常德:101250601益阳:101250700娄底:101250801邵阳:101250901岳阳:101251001张家界:101251101怀化:101251201黔阳:101251301永州:101251401吉首:101251501湘潭:101250201南京:101190101镇江:101190301苏州:101190401南通:101190501扬州:101190601宿迁:101191301徐州:101190801淮安:101190901连云港:101191001常州:101191101泰州:101191201无锡:101190201盐城:101190701哈尔滨:101050101牡丹江:101050301佳木斯:101050401绥化:101050501黑河:101050601双鸭山:101051301伊春:101050801大庆:101050901七台河:101051002鸡西:101051101鹤岗:101051201齐齐哈尔:101050201大兴安岭:101050701长春:101060101延吉:101060301四平:101060401白山:101060901白城:101060601辽源:101060701松原:101060801吉林:101060201通化:101060501沈阳:101070101鞍山:101070301抚顺:101070401本溪:101070501丹东:101070601葫芦岛:101071401营口:101070801阜新:101070901辽阳:101071001铁岭:101071101朝阳:101071201盘锦:101071301大连:101070201锦州:101070701";
16 |
17 | public static void main(String[] args) {
18 | // List cityCode=separate();
19 | // List city=getCity(cityCode);
20 | // List list1=new ArrayList<>();
21 | // List list2=new ArrayList<>();
22 | // for (int i = 0; i < city.size(); i++) {
23 | // if (list1.contains(city.get(i))){
24 | // System.out.println(i);
25 | // list2.add(city.get(i));
26 | // }else {
27 | // list1.add(city.get(i));
28 | // }
29 | // }
30 | // System.out.println(list2);
31 |
32 | getCityJson("澳门");
33 | System.out.println("*******");
34 | }
35 |
36 | /**
37 | * 获得市
38 | * @param province
39 | * @return
40 | */
41 | public static List getCityJson(String province) {
42 | List city=new ArrayList<>();
43 | JsonParser parser = new JsonParser();
44 | JsonObject object = (JsonObject) parser.parse(getJson());
45 | JsonArray zone = object.get("zone").getAsJsonArray();
46 | for (int i = 0; i < zone.size(); i++) {
47 | JsonObject jsonObject = zone.get(i).getAsJsonObject();
48 | if (jsonObject.get("name").getAsString().equals(province)){
49 | JsonArray smallZone=jsonObject.get("zone").getAsJsonArray();
50 | if (province.equals("上海")|province.equals("澳门")|province.equals("重庆")|province.equals("北京")|province.equals("天津")|province.equals("香港")){
51 | JsonObject smallCity=smallZone.get(0).getAsJsonObject();
52 | JsonArray ssmallZone=smallCity.get("zone").getAsJsonArray();
53 | for (int j = 0; j < ssmallZone.size(); j++) {
54 | JsonObject smallCity1=ssmallZone.get(j).getAsJsonObject();
55 | city.add(smallCity1.get("name").getAsString());
56 | }
57 | }else {
58 | for (int j = 0; j < smallZone.size(); j++) {
59 | JsonObject smallCity=smallZone.get(j).getAsJsonObject();
60 | city.add(smallCity.get("name").getAsString());
61 | }
62 | }
63 | }
64 | }
65 | return city;
66 | }
67 |
68 |
69 | /**
70 | * 从json中获取到省的信息
71 | *
72 | * @return
73 | */
74 | public static List getProvinceFromJson() {
75 | List province = new ArrayList<>();
76 | JsonParser parser = new JsonParser();
77 | JsonObject object = (JsonObject) parser.parse(getJson());
78 | JsonArray zone = object.get("zone").getAsJsonArray();
79 | for (int i = 0; i < zone.size(); i++) {
80 | JsonObject jsonObject = zone.get(i).getAsJsonObject();
81 | province.add(jsonObject.get("name").getAsString());
82 | }
83 | return province;
84 | }
85 |
86 | private static String getJson() {
87 | String path = "F:\\github\\DataBase\\design\\src\\web\\city.json";
88 | String result = "";
89 | File file = new File(path);
90 | BufferedReader bufferedReade = null;
91 | try {
92 | FileInputStream inputStream = new FileInputStream(file);
93 | bufferedReade = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
94 | String temp;
95 | while ((temp = bufferedReade.readLine()) != null) {
96 | result = result + temp;
97 | }
98 | bufferedReade.close();
99 | } catch (Exception e) {
100 | e.printStackTrace();
101 | } finally {
102 | if (bufferedReade != null) {
103 | try {
104 | bufferedReade.close();
105 | } catch (IOException e) {
106 | e.printStackTrace();
107 | }
108 | }
109 | }
110 | return result;
111 | }
112 |
113 |
114 | /**
115 | * 将分割好的城市进一步分解为单个城市
116 | *
117 | * @param allCity 一次分割的城市信息
118 | * @return 城市代码
119 | */
120 | public static List getCode(List allCity) {
121 | List city = new ArrayList<>();
122 | for (String string :
123 | allCity) {
124 | string = string.substring(string.length() - 9, string.length());
125 | string = "\'" + string + "\'";
126 | city.add(string);
127 | }
128 | return city;
129 | }
130 |
131 | /**
132 | * 将分割好的城市进一步分解为单个城市
133 | *
134 | * @param allCity 一次分割的城市信息
135 | * @return 城市名称
136 | */
137 | public static List getCity(List allCity) {
138 | List city = new ArrayList<>();
139 | for (String string :
140 | allCity) {
141 | string = string.substring(0, string.length() - 10);
142 | string = "\'" + string + "\'";
143 | city.add(string);
144 | }
145 | return city;
146 | }
147 |
148 | /**
149 | * 全国城市信息切割为单个城市及其对应代码编号
150 | *
151 | * @return 单个城市信息
152 | */
153 | public static List separate() {
154 | List cityCode = new ArrayList<>();
155 | final String weatherCity = "(\\D*):(\\d*)";
156 | Pattern patternCity = Pattern.compile(weatherCity);
157 | Matcher matcherCity = patternCity.matcher(CITY_CODE);
158 | while (matcherCity.find()) {
159 | cityCode.add(matcherCity.group());
160 | }
161 | return cityCode;
162 | }
163 |
164 | /**
165 | * 获取城市对应的编码
166 | *
167 | * @param city 城市
168 | */
169 | private static int getCode(String city) {
170 | int code;
171 | if (CITY_CODE.contains(city)) {
172 | int n = CITY_CODE.indexOf(city);
173 | String result = CITY_CODE.substring(n + 3, n + 12);
174 | code = Integer.valueOf(result);
175 | } else {
176 | System.out.println("输入的城市名称有误,请重新输入");
177 | return 0;
178 | }
179 | return code;
180 | }
181 | }
--------------------------------------------------------------------------------
/design/src/bean/Forecast.java:
--------------------------------------------------------------------------------
1 | package bean;
2 |
3 | public class Forecast {
4 | private String week;
5 | private String sunrise;
6 | private String sunset;
7 | private String high;
8 | private String low;
9 | private String aqi;
10 | private String fengxiang;
11 | private String fenglevel;
12 | private String type;
13 | private String notice;
14 |
15 | public String getWeek() {
16 | return "\'"+week+"\'";
17 | }
18 |
19 | public void setWeek(String week) {
20 | this.week = week;
21 | }
22 |
23 | public String getSunrise() {
24 | return "\'"+sunrise+"\'";
25 | }
26 |
27 | public void setSunrise(String sunrise) {
28 | this.sunrise = sunrise;
29 | }
30 |
31 | public String getSunset() {
32 | return "\'"+sunset+"\'";
33 | }
34 |
35 | public void setSunset(String sunset) {
36 | this.sunset = sunset;
37 | }
38 |
39 | public String getHigh() {
40 | return "\'"+high+"\'";
41 | }
42 |
43 | public void setHigh(String high) {
44 | this.high = high;
45 | }
46 |
47 | public String getLow() {
48 | return "\'"+low+"\'";
49 | }
50 |
51 | public void setLow(String low) {
52 | this.low = low;
53 | }
54 |
55 | public String getAqi() {
56 | return "\'"+aqi+"\'";
57 | }
58 |
59 | public void setAqi(String aqi) {
60 | this.aqi = aqi;
61 | }
62 |
63 | public String getFengxiang() {
64 | return "\'"+fengxiang+"\'";
65 | }
66 |
67 | public void setFengxiang(String fengxiang) {
68 | this.fengxiang = fengxiang;
69 | }
70 |
71 | public String getFenglevel() {
72 | return "\'"+fenglevel+"\'";
73 | }
74 |
75 | public void setFenglevel(String fenglevel) {
76 | this.fenglevel = fenglevel;
77 | }
78 |
79 | public String getType() {
80 | return "\'"+type+"\'";
81 | }
82 |
83 | public void setType(String type) {
84 | this.type = type;
85 | }
86 |
87 | public String getNotice() {
88 | return "\'"+notice+"\'";
89 | }
90 |
91 | public void setNotice(String notice) {
92 | this.notice = notice;
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/design/src/bean/Weather.java:
--------------------------------------------------------------------------------
1 | package bean;
2 |
3 | public class Weather {
4 | private String weatherDate;
5 | private String weatherCity;
6 | private String shidu;
7 | private String quality;
8 | private String wendu;
9 |
10 | public String getWeatherDate() {
11 | return "\'"+weatherDate+"\'";
12 | }
13 |
14 | public void setWeatherDate(String weatherDate) {
15 | this.weatherDate = weatherDate;
16 | }
17 |
18 | public String getWeatherCity() {
19 | return "\'"+weatherCity+"\'";
20 | }
21 |
22 | public void setWeatherCity(String weatherCity) {
23 | this.weatherCity = weatherCity;
24 | }
25 |
26 | public String getShidu() {
27 | return "\'"+shidu+"\'";
28 | }
29 |
30 | public void setShidu(String shidu) {
31 | this.shidu = shidu;
32 | }
33 |
34 | public String getQuality() {
35 | return "\'"+quality+"\'";
36 | }
37 |
38 | public void setQuality(String quality) {
39 | this.quality = quality;
40 | }
41 |
42 | public String getWendu() {
43 | return "\'"+wendu+"\'";
44 | }
45 |
46 | public void setWendu(String wendu) {
47 | this.wendu = wendu;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/design/src/frame/Landing.java:
--------------------------------------------------------------------------------
1 | package frame;
2 |
3 | import tools.MineDialog;
4 |
5 | import javax.swing.*;
6 | import java.awt.*;
7 | import java.awt.event.ActionEvent;
8 | import java.awt.event.ActionListener;
9 | import java.sql.*;
10 | import java.util.Objects;
11 |
12 | public class Landing extends JFrame {
13 |
14 | private static final String DBURL = "jdbc:sqlserver://localhost:1433;databaseName=design";
15 | private static final String userNameSQL = "xieyipeng";
16 | private static final String userPwd = "123456";
17 |
18 | private static int count = 0;
19 | private static JButton loadingButton;//登陆按钮
20 | private static JButton exitButton;//退出按钮
21 | private static JButton forgetButton;//忘记密码
22 | private static JButton loginButton;//注册
23 | private static JFrame loadingFrame;//登陆的框架
24 | public static JComboBox userChooseLanding;
25 | public static JTextField userName;//用户名
26 | private static JPasswordField passWord;//密码
27 | public static final String user[] = {"系统管理员", "气象部门工作人员", "普通用户", "统计人员"};
28 |
29 | private Landing() {
30 | loadingFrame = new JFrame("Loading");
31 | JLabel loadingLabel = new JLabel();
32 | ImageIcon bgim = new ImageIcon(Landing.class.getResource("/frame/icon/Loading.png"));
33 | bgim.setImage(bgim.getImage().getScaledInstance(bgim.getIconWidth(), bgim.getIconHeight(), Image.SCALE_DEFAULT));
34 |
35 | loadingLabel.setIcon(bgim);
36 | loadingFrame.setSize(bgim.getIconWidth(), bgim.getIconHeight());
37 | //380,500
38 | userChooseLanding = new JComboBox<>(user);
39 | userChooseLanding.setBounds(115, 190, 270, 30);
40 |
41 | JLabel userText = new JLabel("用户名");
42 | userText.setBounds(80, 50, 60, 50);
43 | JLabel passwordText = new JLabel("密码");
44 | passwordText.setBounds(80, 120, 60, 50);
45 | userName = new JTextField();
46 | userName.setBounds(150, 50, 270, 50);
47 | passWord = new JPasswordField();
48 | passWord.setBounds(150, 120, 270, 50);
49 |
50 | forgetButton = new JButton("忘记密码");
51 | forgetButton.setBounds(50, 290, 100, 30);
52 | loginButton = new JButton("注册");
53 | loginButton.setBounds(350, 290, 100, 30);
54 |
55 | loadingButton = new JButton("登陆");
56 | loadingButton.setBounds(100, 240, 100, 40);
57 | exitButton = new JButton("退出");
58 | exitButton.setBounds(300, 240, 100, 40);
59 |
60 | initClick();
61 |
62 | loadingLabel.add(userName);
63 | loadingLabel.add(passWord);
64 | loadingLabel.add(userText);
65 | loadingLabel.add(passwordText);
66 | loadingLabel.add(loadingButton);
67 | loadingLabel.add(exitButton);
68 | loadingLabel.add(userChooseLanding);
69 | loadingLabel.add(forgetButton);
70 | loadingLabel.add(loginButton);
71 | loadingFrame.add(loadingLabel);
72 | loadingFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
73 | loadingFrame.setLocation(300, 400);
74 | loadingFrame.setVisible(true);
75 | }
76 |
77 | public static void main(String[] args) {
78 | new Landing();
79 | }
80 |
81 | /**
82 | * 设置登陆和退出的点击事件
83 | */
84 | private static void initClick() {
85 | loginButton.addActionListener(new ActionListener() {
86 | @Override
87 | public void actionPerformed(ActionEvent e) {
88 | new Login();
89 | }
90 | });
91 |
92 | loadingButton.addActionListener(new ActionListener() {
93 | @Override
94 | public void actionPerformed(ActionEvent e) {
95 | String admin = "\'" + userName.getText() + "\'";
96 | char[] password = passWord.getPassword();
97 | String str = "\'" + String.valueOf(password) + "\'";
98 | Connection connection = null;
99 | Statement statement = null;
100 | ResultSet resultSet = null;
101 | switch (Objects.requireNonNull(userChooseLanding.getSelectedItem()).toString()) {
102 | case "系统管理员":
103 | try {
104 | connection = DriverManager.getConnection(DBURL, userNameSQL, userPwd);
105 | statement = connection.createStatement();
106 | String nextOrNot = "select *" +
107 | "FROM management " +
108 | "WHERE management.userName=" + admin;
109 | resultSet = statement.executeQuery(nextOrNot);
110 | if (ifSuccess(str, resultSet)) return;
111 | connection.close();
112 | } catch (SQLException e1) {
113 | e1.printStackTrace();
114 | } finally {
115 | if (resultSet != null) {
116 | try {
117 | resultSet.close();
118 | } catch (SQLException e4) {
119 | e4.printStackTrace();
120 | }
121 | }
122 | if (statement != null) {
123 | try {
124 | statement.close();
125 | } catch (SQLException e2) {
126 | e2.printStackTrace();
127 | }
128 | }
129 | if (connection != null) {
130 | try {
131 | connection.close();
132 | } catch (SQLException e3) {
133 | e3.printStackTrace();
134 | }
135 | }
136 | }
137 | break;
138 | case "普通用户":
139 | try {
140 | connection = DriverManager.getConnection(DBURL, userNameSQL, userPwd);
141 | statement = connection.createStatement();
142 | String nextOrNot = "select *" +
143 | "FROM ordinaryUser " +
144 | "WHERE ordinaryUser.userName=" + admin;
145 | resultSet = statement.executeQuery(nextOrNot);
146 | if (resultSet.next()) {
147 | String a = str.substring(1, str.length() - 1);
148 | String same = resultSet.getString(2).replace(" ", "");
149 | if (a.equals(same)) {
150 | new Main();
151 | loadingFrame.dispose();
152 | } else {
153 | new MineDialog("密码错误,请重新输入密码");
154 | }
155 | return;
156 | } else {
157 | new MineDialog("用户名不存在,请检查用户名是否正确");
158 | }
159 | connection.close();
160 | } catch (SQLException e1) {
161 | e1.printStackTrace();
162 | } finally {
163 | if (resultSet != null) {
164 | try {
165 | resultSet.close();
166 | } catch (SQLException e4) {
167 | e4.printStackTrace();
168 | }
169 | }
170 | if (statement != null) {
171 | try {
172 | statement.close();
173 | } catch (SQLException e2) {
174 | e2.printStackTrace();
175 | }
176 | }
177 | if (connection != null) {
178 | try {
179 | connection.close();
180 | } catch (SQLException e3) {
181 | e3.printStackTrace();
182 | }
183 | }
184 | }
185 | break;
186 | default:
187 | break;
188 | }
189 |
190 | }
191 | });
192 |
193 | exitButton.addActionListener(new ActionListener() {
194 | @Override
195 | public void actionPerformed(ActionEvent e) {
196 | loadingFrame.dispose();
197 | }
198 | });
199 | }
200 |
201 | private static boolean ifSuccess(String str, ResultSet resultSet) throws SQLException {
202 | if (resultSet.next()) {
203 | //检验密码正确与否,登陆进去
204 | String a = str.substring(1, str.length() - 1);
205 | String same = resultSet.getString(2).replace(" ", "");
206 | if (a.equals(same)) {
207 | new Manage();
208 | loadingFrame.dispose();
209 | } else {
210 | new MineDialog("密码错误,请重新输入密码");
211 | }
212 | return true;
213 | } else {
214 | new MineDialog("用户名不存在,请检查用户名是否正确");
215 | }
216 | return false;
217 | }
218 | }
219 |
--------------------------------------------------------------------------------
/design/src/frame/Login.java:
--------------------------------------------------------------------------------
1 | package frame;
2 |
3 | import tools.MineDialog;
4 |
5 | import javax.swing.*;
6 | import java.awt.*;
7 | import java.awt.event.ActionEvent;
8 | import java.awt.event.ActionListener;
9 | import java.sql.*;
10 | import java.util.Objects;
11 |
12 | public class Login extends JFrame {
13 |
14 | public static final String DBURL = "jdbc:sqlserver://localhost:1433;databaseName=design";
15 | public static final String userNameSQL = "xieyipeng";
16 | public static final String userPwd = "123456";
17 |
18 | private static JFrame loginFrame;
19 | private static JTextField userName;
20 | private static JTextField passWord;
21 | private static JButton okLoginButton;
22 | private static JButton exitLoginButton;
23 | private static JComboBox userChoose;
24 | public static final String user[] = {"系统管理员", "气象部门工作人员", "普通用户", "统计人员"};
25 |
26 | public Login() {
27 | loginFrame = new JFrame("注册");
28 |
29 | ImageIcon bgim = new ImageIcon(Landing.class.getResource("/frame/icon/login.png"));
30 | bgim.setImage(bgim.getImage().getScaledInstance(bgim.getIconWidth(), bgim.getIconHeight(), Image.SCALE_DEFAULT));
31 | JLabel loginLabel = new JLabel();
32 | loginLabel.setIcon(bgim);
33 | loginFrame.setSize(bgim.getIconWidth(), bgim.getIconHeight());
34 |
35 | userChoose = new JComboBox<>(user);
36 | userChoose.setBounds(50, 200, 200, 30);
37 |
38 | JLabel userLoginText = new JLabel("用户名");
39 | userLoginText.setBounds(30, 50, 40, 50);
40 | JLabel paswordText = new JLabel("密码");
41 | paswordText.setBounds(30, 120, 40, 50);
42 |
43 | userName = new JTextField();
44 | userName.setBounds(90, 50, 135, 50);
45 | passWord = new JTextField();
46 | passWord.setBounds(90, 120, 135, 50);
47 |
48 | okLoginButton = new JButton("确定");
49 | okLoginButton.setBounds(30, 300, 82, 30);
50 | exitLoginButton = new JButton("取消");
51 | exitLoginButton.setBounds(142, 300, 82, 30);
52 |
53 | initClicks();
54 |
55 |
56 | loginLabel.add(userChoose);
57 | loginLabel.add(userLoginText);
58 | loginLabel.add(userName);
59 | loginLabel.add(paswordText);
60 | loginLabel.add(passWord);
61 | loginLabel.add(okLoginButton);
62 | loginLabel.add(exitLoginButton);
63 |
64 | loginFrame.add(loginLabel);
65 | loginFrame.setVisible(true);
66 | loginFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
67 | loginFrame.setLocation(300, 400);
68 | }
69 |
70 | public static void main(String[] args) {
71 | new Login();
72 | }
73 |
74 | private static void initClicks() {
75 | okLoginButton.addActionListener(new ActionListener() {
76 | @Override
77 | public void actionPerformed(ActionEvent e) {
78 | String name = userName.getText();
79 | String password = passWord.getText();
80 | if (name.length() >= 3 && password.length() >= 3) {
81 | name = "\'" + userName.getText() + "\'";
82 | password = "\'" + passWord.getText() + "\'";
83 | Connection connection = null;
84 | Statement statement = null;
85 | ResultSet resultSet = null;
86 | switch (Objects.requireNonNull(userChoose.getSelectedItem()).toString()) {
87 | case "系统管理员":
88 | try {
89 | connection = DriverManager.getConnection(DBURL, userNameSQL, userPwd);
90 | statement = connection.createStatement();
91 | String select = "SELECT *" +
92 | "FROM management " +
93 | "WHERE management.userName=" + name;
94 | resultSet = statement.executeQuery(select);
95 | if (resultSet.next()) {
96 | new MineDialog("该用户名已被注册过,请选用新的用户名");
97 | System.out.println("相同用户名");
98 | } else {
99 | String SQL = "INSERT INTO management(userName,wordPass)" +
100 | "values(" + name + "," + password + ")";
101 | statement.executeUpdate(SQL);
102 | new MineDialog("注册成功,账号信息已添加到数据库。");
103 | loginFrame.dispose();
104 | }
105 | connection.close();
106 | } catch (SQLException e1) {
107 | e1.printStackTrace();
108 | } finally {
109 | if (statement != null) {
110 | try {
111 | statement.close();
112 | } catch (SQLException e2) {
113 | e2.printStackTrace();
114 | }
115 | }
116 | if (connection != null) {
117 | try {
118 | connection.close();
119 | } catch (SQLException e1) {
120 | e1.printStackTrace();
121 | }
122 | }
123 | }
124 | break;
125 | case "普通用户":
126 | try {
127 | connection = DriverManager.getConnection(DBURL, userNameSQL, userPwd);
128 | statement = connection.createStatement();
129 | String select = "SELECT *" +
130 | "FROM ordinaryUser " +
131 | "WHERE ordinaryUser.userName=" + name;
132 | resultSet = statement.executeQuery(select);
133 | if (resultSet.next()) {
134 | new MineDialog("该用户名已被注册过,请选用新的用户名");
135 | System.out.println("相同用户名");
136 | } else {
137 | String SQL = "INSERT INTO ordinaryUser(userName,wordPass)" +
138 | "values(" + name + "," + password + ")";
139 | statement.executeUpdate(SQL);
140 | new MineDialog("注册成功,账号信息已添加到数据库。");
141 | loginFrame.dispose();
142 | }
143 | connection.close();
144 | } catch (SQLException e1) {
145 | e1.printStackTrace();
146 | } finally {
147 | if (statement != null) {
148 | try {
149 | statement.close();
150 | } catch (SQLException e2) {
151 | e2.printStackTrace();
152 | }
153 | }
154 | if (connection != null) {
155 | try {
156 | connection.close();
157 | } catch (SQLException e1) {
158 | e1.printStackTrace();
159 | }
160 | }
161 | }
162 | break;
163 | default:
164 | break;
165 | }
166 | } else {
167 | new MineDialog("用户名或密码格式不正确,请重新输入");
168 | }
169 | }
170 | });
171 |
172 | exitLoginButton.addActionListener(new ActionListener() {
173 | @Override
174 | public void actionPerformed(ActionEvent e) {
175 | loginFrame.dispose();
176 | }
177 | });
178 | }
179 | }
180 |
--------------------------------------------------------------------------------
/design/src/frame/Main.java:
--------------------------------------------------------------------------------
1 | package frame;
2 |
3 | import bean.Forecast;
4 | import bean.Weather;
5 | import com.google.gson.JsonArray;
6 | import com.google.gson.JsonObject;
7 | import com.google.gson.JsonParser;
8 | import tools.HttpRequest;
9 | import tools.MineDialog;
10 |
11 | import javax.swing.*;
12 | import java.awt.*;
13 | import java.awt.event.ActionEvent;
14 | import java.awt.event.ActionListener;
15 | import java.awt.event.MouseAdapter;
16 | import java.awt.event.MouseEvent;
17 | import java.time.LocalDateTime;
18 | import java.util.ArrayList;
19 | import java.util.Date;
20 | import java.util.List;
21 | import java.util.Objects;
22 |
23 | import static bean.City.getCityJson;
24 | import static bean.City.getProvinceFromJson;
25 |
26 | public class Main extends JFrame {
27 |
28 | public static final String CITY = "太原";
29 | private static final String WEATHER_JSON_URL = "https://www.sojson.com/open/api/weather/json.shtml?city=";
30 | private Weather weather = new Weather();
31 | private List forecasts = new ArrayList<>();
32 |
33 |
34 | private static int year = 0;
35 | private static int month = 0;
36 | private static int day = 0;
37 | private static int hour = 0;
38 | private static int minute = 0;
39 | private static int second = 0;
40 | private static long datatime;
41 |
42 | private static JFrame mainFrame;
43 | private static JLabel mainLabel;
44 |
45 | private static JLabel date;
46 | private static JLabel bigIcon;
47 | private static JLabel wendu;
48 | private static JLabel sheshidu;
49 | private static JLabel weatherType;
50 | private static JLabel highAndLow;
51 | private static JLabel feng;
52 | private static JLabel aqi;
53 |
54 | private static JLabel week1;
55 | private static JLabel bigIcon1;
56 | private static JLabel highAndLow1;
57 | private static JLabel weatherType1;
58 | private static JLabel feng1;
59 | private static JLabel aqi1;
60 |
61 | private static JLabel week2;
62 | private static JLabel bigIcon2;
63 | private static JLabel highAndLow2;
64 | private static JLabel weatherType2;
65 | private static JLabel feng2;
66 | private static JLabel aqi2;
67 |
68 | private static JLabel week3;
69 | private static JLabel bigIcon3;
70 | private static JLabel highAndLow3;
71 | private static JLabel weatherType3;
72 | private static JLabel feng3;
73 | private static JLabel aqi3;
74 |
75 | private static JLabel week4;
76 | private static JLabel bigIcon4;
77 | private static JLabel highAndLow4;
78 | private static JLabel weatherType4;
79 | private static JLabel feng4;
80 | private static JLabel aqi4;
81 |
82 | private static JLabel helloText;
83 |
84 | private static JComboBox provinceChoose;
85 | private static JComboBox cityChoose;
86 |
87 |
88 | public Main() {
89 | mainFrame = new JFrame("城市天气统计管理系统");
90 | mainLabel = new JLabel();
91 |
92 | parse(CITY, weather, forecasts);//解析json
93 |
94 | ImageIcon image = new ImageIcon(Main.class.getResource("/frame/icon/main.png"));
95 | image.setImage(image.getImage().getScaledInstance(image.getIconWidth(), image.getIconHeight(), Image.SCALE_DEFAULT));
96 | mainLabel.setIcon(image);
97 | mainFrame.setSize(image.getIconWidth(), image.getIconHeight());
98 |
99 | getBigLabel(weather, forecasts);
100 | getLabel1(forecasts);
101 | getLabel2(forecasts);
102 | getLabel3(forecasts);
103 | getLabel4(forecasts);
104 |
105 | List prov = getProvinceFromJson();
106 | String[] provs = new String[prov.size()];
107 | prov.toArray(provs);
108 | provinceChoose = new JComboBox<>(provs);
109 | provinceChoose.setSelectedIndex(30);
110 | provinceChoose.setBounds(100, 450, 100, 30);
111 |
112 | /**
113 | * 由IP地址获得真正的地理位置
114 | */
115 | List city = getCityJson("山西");
116 | String[] provs1 = new String[city.size()];
117 | city.toArray(provs1);
118 | cityChoose = new JComboBox<>(provs1);
119 | cityChoose.setSelectedIndex(2);
120 | cityChoose.setBounds(250, 450, 100, 30);
121 |
122 | initHello();
123 | initClick();
124 | addLabel();
125 |
126 | mainLabel.add(provinceChoose);
127 | mainLabel.add(cityChoose);
128 | mainLabel.add(helloText);
129 |
130 | mainFrame.add(mainLabel);
131 | mainFrame.setVisible(true);
132 | mainFrame.setLocation(300, 200);
133 | mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
134 | }
135 |
136 | private void initHello() {
137 | helloText = new JLabel("hello," + Landing.userName.getText() + "。");
138 | helloText.setBounds(850, 550, 150, 30);
139 | }
140 |
141 | public static void main(String[] args) {
142 | //默认太原市
143 | new Main();
144 |
145 | }
146 |
147 |
148 | private static void initClick() {
149 | provinceChoose.addActionListener(new ActionListener() {
150 | @Override
151 | public void actionPerformed(ActionEvent e) {
152 | List city = getCityJson(Objects.requireNonNull(Main.provinceChoose.getSelectedItem()).toString());
153 | String[] provs1 = new String[city.size()];
154 | city.toArray(provs1);
155 | ComboBoxModel aModel1 = new DefaultComboBoxModel(provs1);
156 | cityChoose.setModel(aModel1);
157 | }
158 | });
159 | cityChoose.addActionListener(new ActionListener() {
160 | @Override
161 | public void actionPerformed(ActionEvent e) {
162 | String newCity = Objects.requireNonNull(Main.cityChoose.getSelectedItem()).toString();
163 | Weather newWeather = new Weather();
164 | List newForecasts = new ArrayList<>();
165 | parse(newCity, newWeather, newForecasts);
166 | setBig(newWeather, newForecasts);
167 | setJLabel1(newForecasts);
168 | setJLabel2(newForecasts);
169 | setJLabel3(newForecasts);
170 | setJLabel4(newForecasts);
171 | }
172 | });
173 | /**
174 | * 鼠标移入,移除
175 | */
176 | bigIcon.addMouseListener(new MouseAdapter() {
177 | @Override
178 | public void mouseEntered(MouseEvent e) {
179 | super.mouseEntered(e);
180 | }
181 |
182 | @Override
183 | public void mouseExited(MouseEvent e) {
184 | super.mouseExited(e);
185 | }
186 | });
187 | }
188 |
189 | /**
190 | * 为今天的天气做准备
191 | *
192 | * @param weather
193 | * @param forecasts
194 | */
195 | private void getBigLabel(Weather weather, List forecasts) {
196 | date = new JLabel(changeDate(weather.getWeatherDate()));//更改
197 | date.setFont(new Font("Dialog", Font.BOLD, 15));
198 | date.setForeground(Color.WHITE);
199 | date.setBounds(115, 30, 150, 30);
200 |
201 | bigIcon = new JLabel();
202 | setBigIconSwitch(forecasts);
203 |
204 | wendu = new JLabel(changeWendu(weather.getWendu()));//更改
205 | wendu.setFont(new Font("Dialog", Font.PLAIN, 90));
206 | wendu.setForeground(Color.WHITE);
207 | wendu.setBounds(100, 200, 100, 100);
208 |
209 | sheshidu = new JLabel("℃");
210 | sheshidu.setFont(new Font("Dialog", Font.PLAIN, 20));
211 | sheshidu.setForeground(Color.WHITE);
212 | sheshidu.setBounds(205, 210, 50, 50);
213 |
214 | weatherType = new JLabel(changeWeatherType(forecasts.get(0).getType()));//更改
215 | weatherType.setFont(new Font("Dialog", Font.PLAIN, 20));
216 | weatherType.setForeground(Color.WHITE);
217 | weatherType.setBounds(205, 220, 100, 100);
218 |
219 | highAndLow = new JLabel(changeLow(forecasts.get(0).getLow()) + " - " + changeHign(forecasts.get(0).getHigh()));//更改
220 | highAndLow.setFont(new Font("Dialog", Font.PLAIN, 20));
221 | highAndLow.setForeground(Color.WHITE);
222 | highAndLow.setBounds(110, 310, 200, 30);
223 |
224 | feng = new JLabel(changeFengXiang(forecasts.get(0).getFengxiang()) + " " + changeFengLi(forecasts.get(0).getFenglevel()));//更改
225 | feng.setFont(new Font("Dialog", Font.PLAIN, 20));
226 | feng.setForeground(Color.WHITE);
227 | feng.setBounds(115, 345, 200, 30);
228 |
229 | aqi = new JLabel(changeAqi(forecasts.get(0).getAqi()));//更改
230 | aqi.setFont(new Font("Dialog", Font.PLAIN, 20));
231 | aqi.setForeground(Color.WHITE);
232 | aqi.setBounds(125, 380, 200, 30);
233 | }
234 |
235 | private static void setBig(Weather weather, List forecasts) {
236 | date.setText(changeDate(weather.getWeatherDate()));
237 | setBigIconSwitch(forecasts);
238 | wendu.setText(changeWendu(weather.getWendu()));
239 | weatherType.setText(changeWeatherType(forecasts.get(0).getType()));
240 | highAndLow.setText(changeLow(forecasts.get(0).getLow()) + " - " + changeHign(forecasts.get(0).getHigh()));
241 | feng.setText(changeFengXiang(forecasts.get(0).getFengxiang()) + " " + changeFengLi(forecasts.get(0).getFenglevel()));
242 | aqi.setText(changeAqi(forecasts.get(0).getAqi()));
243 | }
244 |
245 | private static void setBigIconSwitch(List forecasts) {
246 | switch (forecasts.get(0).getType()) {
247 | case "'多云'":
248 | case "'阴'":
249 | ImageIcon image1 = new ImageIcon(Main.class.getResource("/frame/icon/cloudyBig.png"));
250 | image1.setImage(image1.getImage().getScaledInstance(image1.getIconWidth(), image1.getIconHeight(), Image.SCALE_DEFAULT));
251 | bigIcon.setBounds(105, 60, 150, 150);
252 | bigIcon.setIcon(image1);
253 | break;
254 | case "'晴'":
255 | ImageIcon image2 = new ImageIcon(Main.class.getResource("/frame/icon/sunnyBig.png"));
256 | image2.setImage(image2.getImage().getScaledInstance(image2.getIconWidth(), image2.getIconHeight(), Image.SCALE_DEFAULT));
257 | bigIcon.setBounds(105, 60, 150, 150);
258 | bigIcon.setIcon(image2);
259 | break;
260 | case "'雷阵雨'":
261 | case "'小雨'":
262 | System.out.println("小雨");
263 | ImageIcon image3 = new ImageIcon(Main.class.getResource("/frame/icon/rainBig.png"));
264 | image3.setImage(image3.getImage().getScaledInstance(image3.getIconWidth(), image3.getIconHeight(), Image.SCALE_DEFAULT));
265 | bigIcon.setBounds(105, 60, 150, 150);
266 | bigIcon.setIcon(image3);
267 | break;
268 | default:
269 | break;
270 | }
271 | }
272 |
273 | /**
274 | * 为明天天气做准备
275 | *
276 | * @param forecasts
277 | */
278 | private static void setJLabel1(List forecasts) {
279 | week1.setText(changeFengLi(forecasts.get(1).getWeek()));
280 | setLabelswitch1(forecasts);
281 | highAndLow1.setText(changeLow(forecasts.get(1).getLow()) + " - " + changeHign(forecasts.get(1).getHigh()));
282 | weatherType1.setText(changeWeatherType(forecasts.get(1).getType()));
283 | feng1.setText(changeFengXiang(forecasts.get(1).getFengxiang()) + " " + changeFengLi(forecasts.get(1).getFenglevel()));
284 | aqi1.setText(changeAqi(forecasts.get(1).getAqi()));
285 | }
286 |
287 | private void getLabel1(List forecasts) {
288 | week1 = new JLabel(changeFengLi(forecasts.get(1).getWeek()));//更改
289 | week1.setFont(new Font("Dialog", Font.BOLD, 15));
290 | week1.setForeground(Color.WHITE);
291 | week1.setBounds(390, 80, 150, 30);
292 |
293 | bigIcon1 = new JLabel();
294 | System.out.println(forecasts.get(1).getType());
295 | setLabelswitch1(forecasts);
296 |
297 | highAndLow1 = new JLabel(changeLow(forecasts.get(1).getLow()) + " - " + changeHign(forecasts.get(1).getHigh()));
298 | highAndLow1.setFont(new Font("Dialog", Font.PLAIN, 20));
299 | highAndLow1.setForeground(Color.WHITE);
300 | highAndLow1.setBounds(370, 230, 200, 30);
301 |
302 | weatherType1 = new JLabel(changeWeatherType(forecasts.get(1).getType()));
303 | weatherType1.setFont(new Font("Dialog", Font.PLAIN, 20));
304 | weatherType1.setForeground(Color.WHITE);
305 | weatherType1.setBounds(410, 230, 100, 100);
306 |
307 | feng1 = new JLabel(changeFengXiang(forecasts.get(1).getFengxiang()) + " " + changeFengLi(forecasts.get(1).getFenglevel()));
308 | feng1.setFont(new Font("Dialog", Font.PLAIN, 20));
309 | feng1.setForeground(Color.WHITE);
310 | feng1.setBounds(380, 300, 200, 30);
311 |
312 | aqi1 = new JLabel(changeAqi(forecasts.get(1).getAqi()));
313 | aqi1.setFont(new Font("Dialog", Font.PLAIN, 20));
314 | aqi1.setForeground(Color.WHITE);
315 | aqi1.setBounds(405, 340, 200, 30);
316 | }
317 |
318 | private static void setLabelswitch1(List forecasts) {
319 | switch (forecasts.get(1).getType()) {
320 | case "'多云'":
321 | case "'阴'":
322 | ImageIcon image = new ImageIcon(Main.class.getResource("/frame/icon/cloudy.png"));
323 | image.setImage(image.getImage().getScaledInstance(image.getIconWidth(), image.getIconHeight(), Image.SCALE_DEFAULT));
324 | bigIcon1.setBounds(398, 115, 100, 100);
325 | bigIcon1.setIcon(image);
326 | break;
327 | case "'晴'":
328 | ImageIcon image2 = new ImageIcon(Main.class.getResource("/frame/icon/sunny.png"));
329 | image2.setImage(image2.getImage().getScaledInstance(image2.getIconWidth(), image2.getIconHeight(), Image.SCALE_DEFAULT));
330 | bigIcon1.setBounds(398, 115, 100, 100);
331 | bigIcon1.setIcon(image2);
332 | break;
333 | case "'雷阵雨'":
334 | case "'小雨'":
335 | ImageIcon image3 = new ImageIcon(Main.class.getResource("/frame/icon/rain.png"));
336 | image3.setImage(image3.getImage().getScaledInstance(image3.getIconWidth(), image3.getIconHeight(), Image.SCALE_DEFAULT));
337 | bigIcon1.setBounds(398, 115, 100, 100);
338 | bigIcon1.setIcon(image3);
339 | break;
340 | default:
341 | break;
342 | }
343 | }
344 |
345 |
346 | /**
347 | * 为后天天气做准备
348 | *
349 | * @param forecasts
350 | */
351 | private void getLabel2(List forecasts) {
352 | week2 = new JLabel(changeFengLi(forecasts.get(2).getWeek()));//更改
353 | week2.setFont(new Font("Dialog", Font.BOLD, 15));
354 | week2.setForeground(Color.WHITE);
355 | week2.setBounds(560, 80, 150, 30);
356 |
357 | bigIcon2 = new JLabel();
358 | System.out.println(forecasts.get(2).getType());
359 | setLabelSwitch2(forecasts);
360 |
361 | highAndLow2 = new JLabel(changeLow(forecasts.get(2).getLow()) + " - " + changeHign(forecasts.get(2).getHigh()));
362 | highAndLow2.setFont(new Font("Dialog", Font.PLAIN, 20));
363 | highAndLow2.setForeground(Color.WHITE);
364 | highAndLow2.setBounds(535, 230, 200, 30);
365 |
366 | weatherType2 = new JLabel(changeWeatherType(forecasts.get(2).getType()));
367 | weatherType2.setFont(new Font("Dialog", Font.PLAIN, 20));
368 | weatherType2.setForeground(Color.WHITE);
369 | weatherType2.setBounds(575, 230, 100, 100);
370 |
371 | feng2 = new JLabel(changeFengXiang(forecasts.get(2).getFengxiang()) + " " + changeFengLi(forecasts.get(2).getFenglevel()));
372 | feng2.setFont(new Font("Dialog", Font.PLAIN, 20));
373 | feng2.setForeground(Color.WHITE);
374 | feng2.setBounds(540, 300, 200, 30);
375 |
376 | aqi2 = new JLabel(changeAqi(forecasts.get(2).getAqi()));
377 | aqi2.setFont(new Font("Dialog", Font.PLAIN, 20));
378 | aqi2.setForeground(Color.WHITE);
379 | aqi2.setBounds(570, 340, 200, 30);
380 | }
381 |
382 | private static void setJLabel2(List forecasts) {
383 | week2.setText(changeFengLi(forecasts.get(2).getWeek()));
384 | setLabelSwitch2(forecasts);
385 | highAndLow2.setText(changeLow(forecasts.get(2).getLow()) + " - " + changeHign(forecasts.get(2).getHigh()));
386 | weatherType2.setText(changeWeatherType(forecasts.get(2).getType()));
387 | feng2.setText(changeFengXiang(forecasts.get(2).getFengxiang()) + " " + changeFengLi(forecasts.get(2).getFenglevel()));
388 | aqi2.setText(changeAqi(forecasts.get(2).getAqi()));
389 | }
390 |
391 | private static void setLabelSwitch2(List forecasts) {
392 | switch (forecasts.get(2).getType()) {
393 | case "'多云'":
394 | case "'阴'":
395 | ImageIcon image = new ImageIcon(Main.class.getResource("/frame/icon/cloudy.png"));
396 | image.setImage(image.getImage().getScaledInstance(image.getIconWidth(), image.getIconHeight(), Image.SCALE_DEFAULT));
397 | bigIcon2.setBounds(565, 115, 100, 100);
398 | bigIcon2.setIcon(image);
399 | break;
400 | case "'晴'":
401 | ImageIcon image2 = new ImageIcon(Main.class.getResource("/frame/icon/sunny.png"));
402 | image2.setImage(image2.getImage().getScaledInstance(image2.getIconWidth(), image2.getIconHeight(), Image.SCALE_DEFAULT));
403 | bigIcon2.setBounds(565, 115, 100, 100);
404 | bigIcon2.setIcon(image2);
405 | break;
406 | case "'雷阵雨'":
407 | case "'小雨'":
408 | ImageIcon image3 = new ImageIcon(Main.class.getResource("/frame/icon/rain.png"));
409 | image3.setImage(image3.getImage().getScaledInstance(image3.getIconWidth(), image3.getIconHeight(), Image.SCALE_DEFAULT));
410 | bigIcon2.setBounds(565, 115, 100, 100);
411 | bigIcon2.setIcon(image3);
412 | break;
413 | default:
414 | break;
415 | }
416 | }
417 |
418 | /**
419 | * 为大后天天气做准备
420 | *
421 | * @param forecasts
422 | */
423 | private static void setLabelSwitch3(List forecasts) {
424 | switch (forecasts.get(3).getType()) {
425 | case "'多云'":
426 | case "'阴'":
427 | ImageIcon image = new ImageIcon(Main.class.getResource("/frame/icon/cloudy.png"));
428 | image.setImage(image.getImage().getScaledInstance(image.getIconWidth(), image.getIconHeight(), Image.SCALE_DEFAULT));
429 | bigIcon3.setBounds(725, 115, 100, 100);
430 | bigIcon3.setIcon(image);
431 | break;
432 | case "'晴'":
433 | ImageIcon image2 = new ImageIcon(Main.class.getResource("/frame/icon/sunny.png"));
434 | image2.setImage(image2.getImage().getScaledInstance(image2.getIconWidth(), image2.getIconHeight(), Image.SCALE_DEFAULT));
435 | bigIcon3.setBounds(725, 115, 100, 100);
436 | bigIcon3.setIcon(image2);
437 | break;
438 | case "'雷阵雨'":
439 | case "'小雨'":
440 | ImageIcon image3 = new ImageIcon(Main.class.getResource("/frame/icon/rain.png"));
441 | image3.setImage(image3.getImage().getScaledInstance(image3.getIconWidth(), image3.getIconHeight(), Image.SCALE_DEFAULT));
442 | bigIcon3.setBounds(725, 115, 100, 100);
443 | bigIcon3.setIcon(image3);
444 | break;
445 | default:
446 | break;
447 | }
448 | }
449 |
450 | private void getLabel3(List forecasts) {
451 | week3 = new JLabel(changeFengLi(forecasts.get(3).getWeek()));//更改
452 | week3.setFont(new Font("Dialog", Font.BOLD, 15));
453 | week3.setForeground(Color.WHITE);
454 | week3.setBounds(720, 80, 150, 30);
455 |
456 | bigIcon3 = new JLabel();
457 | setLabelSwitch3(forecasts);
458 |
459 | highAndLow3 = new JLabel(changeLow(forecasts.get(3).getLow()) + " - " + changeHign(forecasts.get(3).getHigh()));
460 | highAndLow3.setFont(new Font("Dialog", Font.PLAIN, 20));
461 | highAndLow3.setForeground(Color.WHITE);
462 | highAndLow3.setBounds(700, 230, 200, 30);
463 |
464 | weatherType3 = new JLabel(changeWeatherType(forecasts.get(3).getType()));
465 | weatherType3.setFont(new Font("Dialog", Font.PLAIN, 20));
466 | weatherType3.setForeground(Color.WHITE);
467 | weatherType3.setBounds(740, 230, 100, 100);
468 |
469 | feng3 = new JLabel(changeFengXiang(forecasts.get(3).getFengxiang()) + " " + changeFengLi(forecasts.get(3).getFenglevel()));
470 | feng3.setFont(new Font("Dialog", Font.PLAIN, 20));
471 | feng3.setForeground(Color.WHITE);
472 | feng3.setBounds(705, 300, 200, 30);
473 |
474 | aqi3 = new JLabel(changeAqi(forecasts.get(3).getAqi()));
475 | aqi3.setFont(new Font("Dialog", Font.PLAIN, 20));
476 | aqi3.setForeground(Color.WHITE);
477 | aqi3.setBounds(735, 340, 200, 30);
478 | }
479 |
480 | private static void setJLabel3(List forecasts) {
481 | week3.setText(changeFengLi(forecasts.get(3).getWeek()));
482 | setLabelSwitch3(forecasts);
483 | highAndLow3.setText(changeLow(forecasts.get(3).getLow()) + " - " + changeHign(forecasts.get(3).getHigh()));
484 | weatherType3.setText(changeWeatherType(forecasts.get(3).getType()));
485 | feng3.setText(changeFengXiang(forecasts.get(3).getFengxiang()) + " " + changeFengLi(forecasts.get(3).getFenglevel()));
486 | aqi3.setText(changeAqi(forecasts.get(3).getAqi()));
487 | }
488 |
489 | /**
490 | * 为大大后天天气做准备
491 | *
492 | * @param forecasts
493 | */
494 |
495 | private static void setJLabel4(List forecasts) {
496 | week4.setText(changeFengLi(forecasts.get(4).getWeek()));
497 | setLabelSwitch4(forecasts);
498 | highAndLow4.setText(changeLow(forecasts.get(4).getLow()) + " - " + changeHign(forecasts.get(4).getHigh()));
499 | weatherType4.setText(changeWeatherType(forecasts.get(4).getType()));
500 | feng4.setText(changeFengXiang(forecasts.get(4).getFengxiang()) + " " + changeFengLi(forecasts.get(4).getFenglevel()));
501 | aqi4.setText(changeAqi(forecasts.get(4).getAqi()));
502 | }
503 |
504 | private void getLabel4(List forecasts) {
505 | week4 = new JLabel(changeFengLi(forecasts.get(4).getWeek()));//更改
506 | week4.setFont(new Font("Dialog", Font.BOLD, 15));
507 | week4.setForeground(Color.WHITE);
508 | week4.setBounds(875, 80, 150, 30);
509 |
510 | bigIcon4 = new JLabel();
511 | setLabelSwitch4(forecasts);
512 |
513 | highAndLow4 = new JLabel(changeLow(forecasts.get(4).getLow()) + " - " + changeHign(forecasts.get(4).getHigh()));
514 | highAndLow4.setFont(new Font("Dialog", Font.PLAIN, 20));
515 | highAndLow4.setForeground(Color.WHITE);
516 | highAndLow4.setBounds(855, 230, 200, 30);
517 |
518 | weatherType4 = new JLabel(changeWeatherType(forecasts.get(4).getType()));
519 | weatherType4.setFont(new Font("Dialog", Font.PLAIN, 20));
520 | weatherType4.setForeground(Color.WHITE);
521 | weatherType4.setBounds(890, 230, 100, 100);
522 |
523 | feng4 = new JLabel(changeFengXiang(forecasts.get(4).getFengxiang()) + " " + changeFengLi(forecasts.get(4).getFenglevel()));
524 | feng4.setFont(new Font("Dialog", Font.PLAIN, 20));
525 | feng4.setForeground(Color.WHITE);
526 | feng4.setBounds(860, 300, 200, 30);
527 |
528 | aqi4 = new JLabel(changeAqi(forecasts.get(4).getAqi()));
529 | aqi4.setFont(new Font("Dialog", Font.PLAIN, 20));
530 | aqi4.setForeground(Color.WHITE);
531 | aqi4.setBounds(885, 340, 200, 30);
532 | }
533 |
534 | private static void setLabelSwitch4(List forecasts) {
535 | switch (forecasts.get(4).getType()) {
536 | case "'多云'":
537 | case "'阴'":
538 | ImageIcon image = new ImageIcon(Main.class.getResource("/frame/icon/cloudy.png"));
539 | image.setImage(image.getImage().getScaledInstance(image.getIconWidth(), image.getIconHeight(), Image.SCALE_DEFAULT));
540 | bigIcon4.setBounds(880, 115, 100, 100);
541 | bigIcon4.setIcon(image);
542 | break;
543 | case "'晴'":
544 | ImageIcon image2 = new ImageIcon(Main.class.getResource("/frame/icon/sunny.png"));
545 | image2.setImage(image2.getImage().getScaledInstance(image2.getIconWidth(), image2.getIconHeight(), Image.SCALE_DEFAULT));
546 | bigIcon4.setBounds(880, 115, 100, 100);
547 | bigIcon4.setIcon(image2);
548 | break;
549 |
550 | case "'雷阵雨'":
551 | case "'小雨'":
552 | ImageIcon image3 = new ImageIcon(Main.class.getResource("/frame/icon/rain.png"));
553 | image3.setImage(image3.getImage().getScaledInstance(image3.getIconWidth(), image3.getIconHeight(), Image.SCALE_DEFAULT));
554 | bigIcon4.setBounds(880, 115, 100, 100);
555 | bigIcon4.setIcon(image3);
556 | break;
557 | default:
558 | break;
559 | }
560 | }
561 |
562 |
563 | private static void addLabel() {
564 | mainLabel.add(date);
565 | mainLabel.add(bigIcon);
566 | mainLabel.add(wendu);
567 | mainLabel.add(sheshidu);
568 | mainLabel.add(weatherType);
569 | mainLabel.add(highAndLow);
570 | mainLabel.add(feng);
571 | mainLabel.add(aqi);
572 |
573 | mainLabel.add(week1);
574 | mainLabel.add(bigIcon1);
575 | mainLabel.add(highAndLow1);
576 | mainLabel.add(weatherType1);
577 | mainLabel.add(feng1);
578 | mainLabel.add(aqi1);
579 |
580 | mainLabel.add(week2);
581 | mainLabel.add(bigIcon2);
582 | mainLabel.add(highAndLow2);
583 | mainLabel.add(weatherType2);
584 | mainLabel.add(feng2);
585 | mainLabel.add(aqi2);
586 |
587 | mainLabel.add(week3);
588 | mainLabel.add(bigIcon3);
589 | mainLabel.add(highAndLow3);
590 | mainLabel.add(weatherType3);
591 | mainLabel.add(feng3);
592 | mainLabel.add(aqi3);
593 |
594 | mainLabel.add(week4);
595 | mainLabel.add(bigIcon4);
596 | mainLabel.add(highAndLow4);
597 | mainLabel.add(weatherType4);
598 | mainLabel.add(feng4);
599 | mainLabel.add(aqi4);
600 | }
601 |
602 | private static String changeAqi(String s) {
603 | s = s.substring(1, s.length() - 3);
604 | int a = Integer.valueOf(s);
605 | String result;
606 | if (a >= 0 && a <= 100) {
607 | result = a + " 良";
608 | } else {
609 | result = a + " 轻度";
610 | }
611 | return result;
612 | }
613 |
614 | private static String changeFengLi(String s) {
615 | s = s.substring(1, s.length() - 1);
616 | return s;
617 | }
618 |
619 | private static String changeFengXiang(String s) {
620 | s = s.substring(1, s.length() - 1);
621 | return s;
622 | }
623 |
624 | /**
625 | * @param s
626 | * @return
627 | */
628 | private static String changeLow(String s) {
629 | s = s.substring(4, s.length() - 2);
630 | return s;
631 | }
632 |
633 | /**
634 | * @param wendu
635 | * @return
636 | */
637 | private static String changeHign(String wendu) {
638 | wendu = wendu.substring(4, wendu.length() - 1);
639 | return wendu;
640 | }
641 |
642 | /**
643 | * @param type
644 | * @return
645 | */
646 | private static String changeWeatherType(String type) {
647 | type = type.substring(1, type.length() - 1);
648 | return type;
649 | }
650 |
651 | /**
652 | * 改变温度
653 | *
654 | * @param wendu 温度
655 | * @return 温度
656 | */
657 | private static String changeWendu(String wendu) {
658 | wendu = wendu.substring(1, wendu.length() - 1);
659 | return wendu;
660 | }
661 |
662 | /**
663 | * 添加时间
664 | *
665 | * @param date json获取到的时间
666 | * @return 正常的时间格式
667 | */
668 | private static String changeDate(String date) {
669 | String year = date.substring(1, 5);
670 | String mouth = date.substring(5, 7);
671 | String smallDate = date.substring(7, 9);
672 | return year + "年 " + mouth + "月 " + smallDate + "日";
673 | }
674 |
675 | /**
676 | * 解析json
677 | *
678 | * @param city 解析
679 | * @param weather 天气
680 | * @param forecasts 预测天气
681 | */
682 | public static void parse(String city, Weather weather, List forecasts) {
683 |
684 | LocalDateTime time = LocalDateTime.now();
685 |
686 |
687 | if (datatime != 0) {
688 | if ((((new Date().getTime())-(datatime))/1000)>3){
689 | System.out.println(((new Date().getTime())-(datatime))/1000+"秒");
690 | }else {
691 | new MineDialog("不能连续三秒内多次查询");
692 | return;
693 | }
694 | } else {
695 | new MineDialog("分钟数等于秒数,即初次调用");
696 | }
697 | datatime = new Date().getTime();
698 |
699 |
700 | // if (day != 0 && minute != 0 && second != 0) {
701 | // if (day == time.getDayOfYear()) {
702 | //
703 | // } else if (day < time.getDayOfYear()) {
704 | // if (month > time.getMonthValue()) {
705 | //
706 | // } else {
707 | // if (day > time.getDayOfYear()) ;
708 | // }
709 | // }
710 | // } else {
711 | //
712 | // }
713 | day = time.getDayOfYear();
714 | hour = time.getHour();
715 | minute = time.getMinute();
716 | second = time.getSecond();
717 |
718 | forecasts.clear();
719 | String result = HttpRequest.sendGet(WEATHER_JSON_URL + city);
720 | System.out.println("parse " + city);
721 | System.out.println(result);
722 | JsonParser parser = new JsonParser();
723 | try {
724 | JsonObject object = (JsonObject) parser.parse(result);
725 | weather.setWeatherDate(object.get("date").getAsString());//日期
726 | weather.setWeatherCity(object.get("city").getAsString());//城市
727 | /**
728 | * 获得预期的天气信息
729 | */
730 | JsonObject data = object.get("data").getAsJsonObject();
731 | weather.setShidu(data.get("shidu").getAsString());//湿度
732 | weather.setQuality(data.get("quality").getAsString());//quality
733 | weather.setWendu(data.get("wendu").getAsString());//温度
734 | JsonArray forecast = data.get("forecast").getAsJsonArray();
735 | for (int i = 0; i < forecast.size(); i++) {
736 | JsonObject subObject = forecast.get(i).getAsJsonObject();
737 | Forecast f = new Forecast();
738 | f.setWeek(subObject.get("date").getAsString());
739 | f.setSunrise(subObject.get("sunrise").getAsString());
740 | f.setSunset(subObject.get("sunset").getAsString());
741 | f.setHigh(subObject.get("high").getAsString());
742 | f.setLow(subObject.get("low").getAsString());
743 | f.setAqi(subObject.get("aqi").getAsString());
744 | f.setFengxiang(subObject.get("fx").getAsString());
745 | f.setFenglevel(subObject.get("fl").getAsString());
746 | f.setType(subObject.get("type").getAsString());
747 | f.setNotice(subObject.get("notice").getAsString());
748 | forecasts.add(f);
749 | }
750 | } catch (Exception e) {
751 | e.printStackTrace();
752 | }
753 | }
754 | }
--------------------------------------------------------------------------------
/design/src/frame/icon/Loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/src/frame/icon/Loading.png
--------------------------------------------------------------------------------
/design/src/frame/icon/cloudy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/src/frame/icon/cloudy.png
--------------------------------------------------------------------------------
/design/src/frame/icon/cloudyBig.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/src/frame/icon/cloudyBig.png
--------------------------------------------------------------------------------
/design/src/frame/icon/login.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/src/frame/icon/login.png
--------------------------------------------------------------------------------
/design/src/frame/icon/main.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/src/frame/icon/main.png
--------------------------------------------------------------------------------
/design/src/frame/icon/manage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/src/frame/icon/manage.png
--------------------------------------------------------------------------------
/design/src/frame/icon/rain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/src/frame/icon/rain.png
--------------------------------------------------------------------------------
/design/src/frame/icon/rainBig.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/src/frame/icon/rainBig.png
--------------------------------------------------------------------------------
/design/src/frame/icon/snow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/src/frame/icon/snow.png
--------------------------------------------------------------------------------
/design/src/frame/icon/snowBig.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/src/frame/icon/snowBig.png
--------------------------------------------------------------------------------
/design/src/frame/icon/sunny.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/src/frame/icon/sunny.png
--------------------------------------------------------------------------------
/design/src/frame/icon/sunnyBig.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/design/src/frame/icon/sunnyBig.png
--------------------------------------------------------------------------------
/design/src/reference/Lognin.java:
--------------------------------------------------------------------------------
1 | package reference;
2 |
3 | import javax.swing.*;
4 | import java.awt.*;
5 | import java.awt.event.ActionEvent;
6 | import java.awt.event.ActionListener;
7 | import java.awt.event.InputEvent;
8 |
9 | public class Lognin {
10 | JFrame frame = new JFrame("城市天气统计管理系统");
11 | JButton lognin = new JButton("登陆");
12 | String user[] = {"系统管理员", "气象部门工作人员", "普通用户", "统计人员"};
13 | JComboBox userChoose = new JComboBox<>(user);
14 | JList userList = new JList<>(user);
15 | JMenuBar menuBar = new JMenuBar();
16 | JMenu file = new JMenu("文件");
17 | JMenu edit = new JMenu("编辑");
18 | JMenu fromat = new JMenu("格式");
19 | JMenuItem newItem = new JMenuItem("新建");
20 | JMenuItem saveItem = new JMenuItem("保存");
21 | JMenuItem commentItem = new JMenuItem("注释");
22 | JPopupMenu pop = new JPopupMenu();
23 | JTextArea ta = new JTextArea(8, 20);
24 | ButtonGroup flavorGroup = new ButtonGroup();
25 | JMenuItem canceItem = new JMenuItem("取消注释");
26 | JRadioButtonMenuItem metalItem = new JRadioButtonMenuItem("Metal风格", true);
27 | JRadioButtonMenuItem windowsItem = new JRadioButtonMenuItem("Windows风格", true);
28 |
29 | public void init() {
30 | JPanel bottom = new JPanel();
31 | bottom.add(lognin);
32 | frame.add(bottom, BorderLayout.SOUTH);
33 |
34 | JPanel checkJPanel = new JPanel();
35 | checkJPanel.add(userChoose);
36 |
37 | Box topLeft = Box.createVerticalBox();
38 | JScrollPane taJspa = new JScrollPane(ta);
39 |
40 | topLeft.add(checkJPanel);
41 | topLeft.add(taJspa);
42 |
43 | Box top = Box.createHorizontalBox();
44 | top.add(topLeft);
45 | top.add(userList);
46 | frame.add(top);
47 |
48 | newItem.setAccelerator(KeyStroke.getKeyStroke('N', InputEvent.CTRL_MASK));
49 | newItem.addActionListener(new ActionListener() {
50 | @Override
51 | public void actionPerformed(ActionEvent e) {
52 | ta.append("用户单机了新建菜单\n");
53 | }
54 | });
55 | file.add(newItem);
56 | edit.add(saveItem);
57 | canceItem.setToolTipText("将程序代码都注释起来");
58 | fromat.add(commentItem);
59 | fromat.add(canceItem);
60 | edit.add(fromat);
61 | menuBar.add(file);
62 | menuBar.add(edit);
63 |
64 | frame.setJMenuBar(menuBar);
65 | flavorGroup.add(metalItem);
66 | flavorGroup.add(windowsItem);
67 | ActionListener flavorListener = new ActionListener() {
68 | @Override
69 | public void actionPerformed(ActionEvent e) {
70 | try {
71 | switch (e.getActionCommand()) {
72 | case "Metal风格":
73 | changeFlavor(1);
74 | break;
75 | case "Windows风格":
76 | changeFlavor(2);
77 | break;
78 | default:
79 | break;
80 | }
81 | } catch (Exception e1) {
82 | e1.printStackTrace();
83 | }
84 | }
85 | };
86 | metalItem.addActionListener(flavorListener);
87 | windowsItem.addActionListener(flavorListener);
88 | ta.setComponentPopupMenu(pop);
89 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
90 | frame.pack();
91 | frame.setVisible(true);
92 | }
93 |
94 | private void changeFlavor(int i) throws Exception {
95 | switch (i) {
96 | case 1:
97 | UIManager.setLookAndFeel("Javax.swing.plaf.metal.MetalLookAndFeel");
98 | break;
99 | case 2:
100 | UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsClassicLookAndFell");
101 | break;
102 | default:
103 | break;
104 | }
105 | SwingUtilities.updateComponentTreeUI(frame.getContentPane());
106 | SwingUtilities.updateComponentTreeUI(menuBar);
107 | SwingUtilities.updateComponentTreeUI(pop);
108 | }
109 |
110 | public static void main(String[] args) {
111 | new Lognin().init();
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/design/src/test.java:
--------------------------------------------------------------------------------
1 | import java.awt.BorderLayout;
2 | import java.awt.GridLayout;
3 | import java.awt.event.ActionEvent;
4 | import java.awt.event.ActionListener;
5 | import java.time.LocalDateTime;
6 | import javax.swing.JButton;
7 | import javax.swing.JFrame;
8 | import javax.swing.JPanel;
9 | import javax.swing.JScrollPane;
10 | import javax.swing.JTable;
11 | import javax.swing.table.DefaultTableModel;
12 |
13 | /**
14 | *
15 | * @author wenliang
16 | */
17 | public class test {
18 | public static void main(String[] args) {
19 | }
20 | }
--------------------------------------------------------------------------------
/design/src/tools/HttpRequest.java:
--------------------------------------------------------------------------------
1 | package tools;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.IOException;
5 | import java.io.InputStreamReader;
6 | import java.io.PrintWriter;
7 | import java.net.URL;
8 | import java.net.URLConnection;
9 | import java.util.List;
10 | import java.util.Map;
11 |
12 | public class HttpRequest {
13 | /**
14 | * 发送GET请求
15 | *
16 | * @param url 请求的网站
17 | * @return 服务器返回的字符串
18 | */
19 | public static String sendGet(String url) {
20 | String result = "";
21 | BufferedReader bufferedReader = null;
22 | try {
23 | url = url.replace(" ", "%20");
24 | URL urlResult = new URL(url);
25 | URLConnection connection = urlResult.openConnection();
26 | // 防范415错误
27 | connection.setRequestProperty("accept", "*/*");
28 | connection.setRequestProperty("connection", "Keep-Alive");
29 | connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
30 | connection.setRequestProperty("User-Agent",
31 | "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0");
32 | connection.connect();
33 | // Map> map = connection.getHeaderFields();
34 | // for (String key :
35 | // map.keySet()) {
36 | // System.out.println(key + "->" + map.get(key));
37 | // }
38 | bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
39 | String line;
40 | while ((line = bufferedReader.readLine()) != null) {
41 | result = result + line;
42 | }
43 | } catch (Exception e) {
44 | System.out.println("发送Get请求出现异常" + e);
45 | } finally {
46 | try {
47 | if (bufferedReader != null) {
48 | bufferedReader.close();
49 | }
50 | } catch (IOException e) {
51 | e.printStackTrace();
52 | }
53 | }
54 | return result;
55 | }
56 |
57 | /**
58 | * 发送post请求
59 | * @param url 网站
60 | * @param param 请求参数
61 | * @return 返回字符串
62 | */
63 | public static String sendPost(String url, String param) {
64 | PrintWriter printWriter = null;
65 | BufferedReader bufferedReader = null;
66 | String result = "";
67 | try {
68 | url = url.replace(" ", "%20");
69 | URL urlResult = new URL(url);
70 | URLConnection connection = urlResult.openConnection();
71 | connection.setRequestProperty("accept", "*/*");
72 | connection.setRequestProperty("connection", "Keep-Alive");
73 | connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
74 | connection.setRequestProperty("User-Agent",
75 | "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0");
76 | connection.setDoInput(true);
77 | connection.setDoOutput(true);
78 | printWriter = new PrintWriter(connection.getOutputStream());
79 | printWriter.print(param);
80 | printWriter.flush();
81 | bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
82 | String line;
83 | while ((line = bufferedReader.readLine()) != null) {
84 | result = result + line;
85 | }
86 | } catch (Exception e) {
87 | System.out.println("发送post请求出现错误" + e);
88 | } finally {
89 | try {
90 | if (printWriter != null) {
91 | printWriter.close();
92 | }
93 | if (bufferedReader != null) {
94 | bufferedReader.close();
95 | }
96 | } catch (IOException e) {
97 | e.printStackTrace();
98 | }
99 | }
100 | return result;
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/design/src/tools/MineDialog.java:
--------------------------------------------------------------------------------
1 | package tools;
2 |
3 | import javax.swing.*;
4 | import java.awt.event.ActionEvent;
5 | import java.awt.event.ActionListener;
6 |
7 | public class MineDialog {
8 | private static JButton okMineDialog;
9 | private static JFrame mineDialogFrame;
10 | public MineDialog(String text){
11 | mineDialogFrame = new JFrame("MineDialog");
12 | mineDialogFrame.setSize(300,150);
13 | JLabel loginAgainText=new JLabel(text);
14 | loginAgainText.setBounds(20,20,245,30);
15 |
16 | okMineDialog =new JButton("确定");
17 | okMineDialog.setBounds(100,60,100,30);
18 |
19 | JLabel loginAgainLabel=new JLabel();
20 | loginAgainLabel.add(loginAgainText);
21 | loginAgainLabel.add(okMineDialog);
22 |
23 | initClicks();
24 |
25 | mineDialogFrame.add(loginAgainLabel);
26 | mineDialogFrame.setVisible(true);
27 | mineDialogFrame.setLocation(300, 400);
28 | mineDialogFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
29 | }
30 |
31 | private void initClicks() {
32 | okMineDialog.addActionListener(new ActionListener() {
33 | @Override
34 | public void actionPerformed(ActionEvent e) {
35 | mineDialogFrame.dispose();
36 | }
37 | });
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/design/src/web/beijing.json:
--------------------------------------------------------------------------------
1 | {
2 | "date":"20180618",
3 | "message":"Success !",
4 | "status":200,
5 | "city":"北京",
6 | "count":17,
7 | "data":{
8 | "shidu":"80%",
9 | "pm25":57.0,
10 | "pm10":64.0,
11 | "quality":"良",
12 | "wendu":"22",
13 | "ganmao":"极少数敏感人群应减少户外活动",
14 | "yesterday":{
15 | "date":"17日星期日",
16 | "sunrise":"04:45",
17 | "high":"高温 28.0℃",
18 | "low":"低温 20.0℃",
19 | "sunset":"19:45",
20 | "aqi":50.0,
21 | "fx":"南风",
22 | "fl":"<3级",
23 | "type":"阵雨",
24 | "notice":"阵雨来袭,出门记得带伞"
25 | },
26 | "forecast":[
27 | {
28 | "date":"18日星期一",
29 | "sunrise":"04:45",
30 | "high":"高温 30.0℃",
31 | "low":"低温 21.0℃",
32 | "sunset":"19:45",
33 | "aqi":95.0,
34 | "fx":"西南风",
35 | "fl":"<3级",
36 | "type":"雷阵雨",
37 | "notice":"带好雨具,别在树下躲雨"
38 | },
39 | {
40 | "date":"19日星期二",
41 | "sunrise":"04:45",
42 | "high":"高温 32.0℃",
43 | "low":"低温 21.0℃",
44 | "sunset":"19:45",
45 | "aqi":59.0,
46 | "fx":"东北风",
47 | "fl":"<3级",
48 | "type":"多云",
49 | "notice":"阴晴之间,谨防紫外线侵扰"
50 | },
51 | {
52 | "date":"20日星期三",
53 | "sunrise":"04:46",
54 | "high":"高温 34.0℃",
55 | "low":"低温 22.0℃",
56 | "sunset":"19:46",
57 | "aqi":52.0,
58 | "fx":"北风",
59 | "fl":"<3级",
60 | "type":"晴",
61 | "notice":"愿你拥有比阳光明媚的心情"
62 | },
63 | {
64 | "date":"21日星期四",
65 | "sunrise":"04:46",
66 | "high":"高温 34.0℃",
67 | "low":"低温 23.0℃",
68 | "sunset":"19:46",
69 | "aqi":81.0,
70 | "fx":"南风",
71 | "fl":"<3级",
72 | "type":"多云",
73 | "notice":"阴晴之间,谨防紫外线侵扰"
74 | },
75 | {
76 | "date":"22日星期五",
77 | "sunrise":"04:46",
78 | "high":"高温 31.0℃",
79 | "low":"低温 21.0℃",
80 | "sunset":"19:46",
81 | "aqi":94.0,
82 | "fx":"东南风",
83 | "fl":"<3级",
84 | "type":"多云",
85 | "notice":"阴晴之间,谨防紫外线侵扰"
86 | }
87 | ]
88 | }
89 | }
--------------------------------------------------------------------------------
/design/src/web/taiyuan.json:
--------------------------------------------------------------------------------
1 | {
2 | "date": "20180622",
3 | "message": "Success !",
4 | "status": 200,
5 | "city": "太原",
6 | "count": 2,
7 | "data": {
8 | "shidu": "78%",
9 | "pm25": 29.0,
10 | "pm10": 71.0,
11 | "quality": "良",
12 | "wendu": "18",
13 | "ganmao": "极少数敏感人群应减少户外活动",
14 | "yesterday": {
15 | "date": "21日星期四",
16 | "sunrise": "05:07",
17 | "high": "高温 27.0℃",
18 | "low": "低温 16.0℃",
19 | "sunset": "19:55",
20 | "aqi": 107.0,
21 | "fx": "东风",
22 | "fl": "<3级",
23 | "type": "中雨",
24 | "notice": "记得随身携带雨伞哦"
25 | },
26 | "forecast": [
27 | {
28 | "date": "22日星期五",
29 | "sunrise": "05:08",
30 | "high": "高温 31.0℃",
31 | "low": "低温 18.0℃",
32 | "sunset": "19:55",
33 | "aqi": 64.0,
34 | "fx": "南风",
35 | "fl": "<3级",
36 | "type": "多云",
37 | "notice": "阴晴之间,谨防紫外线侵扰"
38 | },
39 | {
40 | "date": "23日星期六",
41 | "sunrise": "05:08",
42 | "high": "高温 34.0℃",
43 | "low": "低温 20.0℃",
44 | "sunset": "19:55",
45 | "aqi": 73.0,
46 | "fx": "东风",
47 | "fl": "<3级",
48 | "type": "晴",
49 | "notice": "愿你拥有比阳光明媚的心情"
50 | },
51 | {
52 | "date": "24日星期日",
53 | "sunrise": "05:08",
54 | "high": "高温 33.0℃",
55 | "low": "低温 19.0℃",
56 | "sunset": "19:56",
57 | "aqi": 69.0,
58 | "fx": "南风",
59 | "fl": "<3级",
60 | "type": "多云",
61 | "notice": "阴晴之间,谨防紫外线侵扰"
62 | },
63 | {
64 | "date": "25日星期一",
65 | "sunrise": "05:08",
66 | "high": "高温 30.0℃",
67 | "low": "低温 20.0℃",
68 | "sunset": "19:56",
69 | "aqi": 67.0,
70 | "fx": "东北风",
71 | "fl": "<3级",
72 | "type": "小雨",
73 | "notice": "雨虽小,注意保暖别感冒"
74 | },
75 | {
76 | "date": "26日星期二",
77 | "sunrise": "05:09",
78 | "high": "高温 27.0℃",
79 | "low": "低温 17.0℃",
80 | "sunset": "19:56",
81 | "aqi": 60.0,
82 | "fx": "东北风",
83 | "fl": "<3级",
84 | "type": "多云",
85 | "notice": "阴晴之间,谨防紫外线侵扰"
86 | }
87 | ]
88 | }
89 | }
--------------------------------------------------------------------------------
/experiment_four.sql:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/experiment_four.sql
--------------------------------------------------------------------------------
/experiment_one.sql:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/experiment_one.sql
--------------------------------------------------------------------------------
/experiment_three.sql:
--------------------------------------------------------------------------------
1 | --***********************实验三***********************--
2 | insert
3 | into Student(Sno,Sname,Ssex,Sage,Sdep)
4 | values('95007','张丽娜','女',18,'IS')
5 |
6 | insert
7 | into SC(Sno,Cno)
8 | values('95007','1')
9 |
10 | create table DeptAvg(
11 | Dept char(20) primary key,
12 | Davg smallint
13 | )
14 | insert
15 | into DeptAvg(Dept,Davg)
16 | select Sdep,avg(Grande)
17 | from Student left outer join SC on (Student.Sno=SC.Sno)
18 | group by Sdep
19 |
20 | update Student
21 | set Sage=22
22 | where Student.Sno='201215123'
23 |
24 | update Student
25 | set Sage=Sage+1
26 | where Sage is not null
27 |
28 | update SC
29 | set Grande=0
30 | where Sno in(
31 | select Sno
32 | from Student
33 | where Student.Sdep='IS'
34 | )
35 |
36 | delete
37 | from Student
38 | where Sno='95001'
39 |
40 | delete
41 | from SC
42 | where Sno in(
43 | select Sno
44 | from Student
45 | where Sdep='IS'
46 | )
47 |
48 | create view CS_S(Vno,Vname,Vage,Vdep)
49 | as select
50 | Sno,Sname,Sage,Sdep
51 | from Student
52 | where Sdep='CS'
53 |
54 | --drop view CS_S
55 |
56 | insert
57 | into CS_S
58 | values('95002','李华华',18,'IS')
59 |
60 | insert
61 | into CS_S
62 | values('95003','王冬冬',20,'CS')
63 |
64 | select Vno,Vage
65 | from CS_S
66 |
67 | select Vno,Vage
68 | from CS_S
69 | where Vno in(
70 | select Sno
71 | from SC
72 | where Cno='2'
73 | )
74 |
75 | create view S_C_GREADE(S_C_no,S_C_name,S_C_Cno,S_C_Cname,S_C_Grand)
76 | as select distinct
77 | Student.Sno,Student.Sname,SC.Cno,Course.Cname,SC.Grande
78 | From SC left outer join Student on(sc.sno=student.sno) left outer join Course on(SC.cno=Course.cno)
79 |
80 | create view V_IS_Score(V_IS_Sno,V_IS_Sname)
81 | as select
82 | Student.Sno,Student.Sname
83 | from Student
84 | where Student.Sno in(
85 | select
86 | Sno
87 | from SC
88 | where SC.Grande>90 and SC.Cno='1')
89 |
90 | create view V_NUM_AVG(V_Dept,V_Num,V_Age_Avg)
91 | as select
92 | Sdep,count(Sno),avg(Sage)
93 | from Student
94 | group by Sdep
95 |
96 | select *
97 | from S_C_GREADE
98 |
99 | select *
100 | from V_IS_Score
101 |
102 | select *
103 | from V_NUM_AVG
104 |
105 | select *
106 | from S_C_GREADE
107 | where S_C_GREADE.S_C_Cno='1'
108 |
109 | create view V_MAStudent(Vno,Vname,Vage,Vdept)
110 | as select
111 | Sno,Sname,Sage,Sdep
112 | from Student
113 | where Sdep='MA'
114 |
115 | select *
116 | from V_MAStudent
117 |
118 | select *
119 | from V_MAStudent
120 | where Vage<20
121 |
122 | update V_MAStudent
123 | set Vname='王五'
124 | where Vno='2002151211'
125 |
126 | insert
127 | into V_MAStudent
128 | values('200215126','赵新','20','MA')
129 |
130 | drop view V_MAStudent
131 |
132 | drop view V_NUM_AVG
133 |
134 | --*************2部分*************--
135 | --1)向选题表中插入一条记录(‘H06’,‘学生成绩管理系统’,‘已选’,‘T03’,’0706034107’)
136 | insert
137 | into Desion
138 | values('H06','学生成绩管理系统','已选',null,null,'T03','0706034107')
139 |
140 | --2)将教师李霞的学历改为“博士”。
141 | update Teacher
142 | set Ttitle='博士'
143 | where Tname='李霞'
144 |
145 | --3)删除“1组”所有学生的选题情况。
146 | delete
147 | from Desion
148 | where Desion.Sno in(
149 | select Sno
150 | from Student
151 | where Sgroup='1')
152 |
153 |
154 | --4) 建立选题学生选题情况的视图(包括学号,姓名,题目名称,指导教师姓名,指导老师联系电话)
155 | --(视图名称和视图中包含的属性名称自拟)
156 | create view V_S_Course(Vno,Vname,VHname,VTname,VTtel)
157 | as select Student.Sno,Student.Sname,Desion.Hname,Teacher.Tname,Teacher.Ttel
158 | from Student left outer join Desion on(Student.Sno=Desion.Sno) left outer join Teacher on (Desion.Tno=Teacher.Tno)
159 |
160 | select *
161 | from V_S_Course
162 |
163 | --5)利用4)建立的视图查询所有杨坚老师所带学生的学号,姓名和题目名称。
164 | select Vno,Vname,VHname
165 | from V_S_Course
166 | where VTname='杨坚'
--------------------------------------------------------------------------------
/experiment_two.sql:
--------------------------------------------------------------------------------
1 | --***********************实验二***********************--
2 | --**********************第一部分**********************--
3 | create table SC(
4 | Sno char(9),
5 | Cno char(4),
6 | Grande smallint,
7 | PRIMARY KEY(SNO,CNO),
8 | )
9 |
10 | --查询选修了课程的学生的学号;
11 | select distinct Sno
12 | from SC
13 |
14 | --查询学生姓名和出生年份,将列别名改为XM和CSNF;
15 | select Sname Xm,2018-Sage CSNF
16 | from Student
17 |
18 | --查询年龄在18-20之间的学号,姓名,系
19 | select Sno,Sname,Sdep
20 | from Student
21 | where Sage>=18 and Sage<=20;
22 |
23 | --查询信息系(IS)、数学系(MA)和计算机科学系(CS)学生的姓名和性别。
24 | /*
25 | select Sname,Ssex
26 | from Student
27 | where Sdep='CS';
28 |
29 | select Sname,Ssex
30 | from Student
31 | where Sdep='MA';
32 |
33 | select Sname,Ssex
34 | from Student
35 | where Sdep='IS';
36 | */
37 | select Sname,Ssex
38 | from Student
39 | where Sdep in ('IS','MA','CS')
40 |
41 | --用LIKE查询课程名为DB_S程的课程号和学分。
42 | select Cno,Ccredit
43 | from Course
44 | where Cname like '数据%'
45 |
46 | --查所有有成绩的学生学号和课程号。
47 | /*
48 | select distinct Sno,Cno
49 | from SC
50 | where SC.Grande!='NULL'
51 | */
52 | select distinct Sno,Cno
53 | from SC
54 | where SC.Grande is not NULL
55 |
56 | --查询全体学生情况,查询结果按所在系的系号升序排列,同一系中的学生按年龄升序排列
57 | --!
58 | select *
59 | from Student
60 | order by Sdep,Sage
61 |
62 | --查询选修了课程的学生人数。
63 | --!!!!
64 | select Cno,count(Sno) as 学生人数
65 | from SC
66 | where Cno='3'
67 | group by Cno
68 |
69 | --计算1号课程的学生平均成绩。
70 | --!
71 | select Cno,avg(Grande) as 平均成绩
72 | from SC
73 | where Cno='1'
74 | group by Cno
75 |
76 | --查询有3人以上(含3人)同学选修课程的课程号。
77 | --!
78 | select Cno
79 | from SC
80 | group by Cno
81 | having count(Sno)>=3
82 |
83 | --查询1号课程的间接先修课。
84 | --!!!!!!
85 | select first.Cno,second.Cpno Cppno
86 | from Course first,Course second
87 | where first.Cno='1' and second.Cno=first.Cpno
88 |
89 | --查询每个学生的学号、姓名、选修的课程名及成绩。
90 | select Student.Sno,Sname,Cname,Grande
91 | from Course,SC,Student
92 | where SC.Sno=Student.Sno and SC.Cno=Course.Cno;
93 |
94 | --找出每个学生等于他选修课程平均成绩的课程号。
95 | --!
96 | select SC.Sno,Cno
97 | from SC,(select SNO,avg(Grande) NewGrande
98 | from SC
99 | group by Sno)as NewSC
100 | where SC.Sno=NewSC.Sno and Grande=NewGrande
101 |
102 | --**********************第二部分**********************--
103 | --查询全体学生的学号和姓名和电话。
104 | select Sno,Sname,Stel
105 | from Student
106 |
107 | --查询全体学生的基本情况。
108 | select *
109 | from Student
110 |
111 | --查询带了毕业生的老师的教师号。
112 | select Tno
113 | from Teacher
114 | where Tright='true'
115 |
116 | --查询教师“朱龙”基本情况。
117 | select *
118 | from Teacher
119 | where Tname='朱龙'
120 |
121 | --查询所有姓“王”同学的基本情况。
122 | select *
123 | from Student
124 | where Sname like '王%'
125 |
126 | --统计每种学历老师的人数。
127 | --!
128 | select Tdegree,count(Tno) counts
129 | from Teacher
130 | group by Tdegree
131 |
132 | --查询1组老师所带毕业生的基本情况(包括学号,姓名,教师号,教师姓名,毕业设计题目)
133 | --(注:1组老师只能带1组的学生)
134 | --!
135 | select Student.Sno,Sname,Teacher.Tno,Tname,Hname
136 | FROM Student,Desion,Teacher
137 | WHERE Teacher.Tno=Desion.Tno and Desion.Sno=Student.Sno
138 | and Tgroup=1 and Sgroup=1
139 |
140 | --查询所有学生的选题情况(包括没有选题的学生),包括学号,姓名,题目名称,教师名称。
141 | --(注:要求老师的组号和学生的组号相一致.)
142 | /*
143 | create view S_B as
144 | select STUDENT.SNO,SNAME,SSEX,SCLASS,STEL,SGROUP,SPASSWORD,Hno,Hname,Tno
145 | from Student left outer join Desion ON(Desion.Sno=Student.Sno)
146 |
147 | select S_B.Sno,S_B.Sname,S_B.Hname,Tname
148 | from S_B left outer join Teacher on(S_B.Tno=Teacher.Tno)
149 | */
150 | select distinct Student.Sno,Sname,Hname,Desion.Tno
151 | from Student,Desion,Teacher
152 | where Student.Sgroup=Teacher.Tgroup and Desion.Sno=Student.Sno
153 |
--------------------------------------------------------------------------------
/jar/.idea/.name:
--------------------------------------------------------------------------------
1 | Database
--------------------------------------------------------------------------------
/jar/.idea/artifacts/curd_jdbc_xieyipeng.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/out/artifacts/curd_jdbc_xieyipeng
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/jar/.idea/libraries/curd_jdbc_xieyipeng.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/jar/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/jar/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/jar/.idea/uiDesigner.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | -
6 |
7 |
8 | -
9 |
10 |
11 | -
12 |
13 |
14 | -
15 |
16 |
17 | -
18 |
19 |
20 |
21 |
22 |
23 | -
24 |
25 |
26 |
27 |
28 |
29 | -
30 |
31 |
32 |
33 |
34 |
35 | -
36 |
37 |
38 |
39 |
40 |
41 | -
42 |
43 |
44 |
45 |
46 | -
47 |
48 |
49 |
50 |
51 | -
52 |
53 |
54 |
55 |
56 | -
57 |
58 |
59 |
60 |
61 | -
62 |
63 |
64 |
65 |
66 | -
67 |
68 |
69 |
70 |
71 | -
72 |
73 |
74 | -
75 |
76 |
77 |
78 |
79 | -
80 |
81 |
82 |
83 |
84 | -
85 |
86 |
87 |
88 |
89 | -
90 |
91 |
92 |
93 |
94 | -
95 |
96 |
97 |
98 |
99 | -
100 |
101 |
102 | -
103 |
104 |
105 | -
106 |
107 |
108 | -
109 |
110 |
111 | -
112 |
113 |
114 |
115 |
116 | -
117 |
118 |
119 | -
120 |
121 |
122 |
123 |
124 |
--------------------------------------------------------------------------------
/jar/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/jar/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
87 |
88 |
89 |
90 | main
91 | Types
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 | true
125 | DEFINITION_ORDER
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 | Google Web Toolkit issues
148 |
149 |
150 |
151 |
152 | NonJREEmulationClassesInClientCode
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 | 1534656027918
281 |
282 |
283 | 1534656027918
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 | curd_jdbc_xieyipeng
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 | No facets are configured
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 | 9.0
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 | Database
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 | 9.0
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 | curd_jdbc_xieyipeng
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
--------------------------------------------------------------------------------
/jar/Database.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/jar/out/production/Database/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/jar/out/production/Database/1.png
--------------------------------------------------------------------------------
/jar/out/production/Database/libs/curd_jdbc_xieyipeng.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/jar/out/production/Database/libs/curd_jdbc_xieyipeng.jar
--------------------------------------------------------------------------------
/jar/out/production/Database/libs/mssql-jdbc-7.0.0.jre8.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/jar/out/production/Database/libs/mssql-jdbc-7.0.0.jre8.jar
--------------------------------------------------------------------------------
/jar/out/production/Database/test.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/jar/out/production/Database/test.class
--------------------------------------------------------------------------------
/jar/src/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/jar/src/1.png
--------------------------------------------------------------------------------
/jar/src/SocketTest.java:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * Created with IntelliJ IDEA.
4 | * TODO:
5 | * User: xieyipeng
6 | * Date: 2018-08-20
7 | * Time: 10:58
8 | */
9 | public class SocketTest {
10 | public static void main(String[] args) {
11 | // Connection connection=myConnection.connect("xieyipeng","123456","design");
12 | // if (connection!=null){
13 | // System.out.println("123");
14 | // }else {
15 | // System.out.println("234");
16 | // }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/jar/src/libs/curd_jdbc_xieyipeng.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/jar/src/libs/curd_jdbc_xieyipeng.jar
--------------------------------------------------------------------------------
/jar/src/libs/mssql-jdbc-7.0.0.jre8.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xieyipeng/DataBase/641a69ae5140e3bc6771b99265cfb16c277d240b/jar/src/libs/mssql-jdbc-7.0.0.jre8.jar
--------------------------------------------------------------------------------
/课本/第一章-绪论.md:
--------------------------------------------------------------------------------
1 | # 第一章 - 绪论
2 |
3 | ## 数据库系统概述
4 |
5 | ### 数据库的4个基本概念:
6 |
7 | 1. 数据:**描述事物的符号记录称为数据。**数据的含义成为数据的语义,数据与其语义是不可分割的。
8 | 2. 数据库:**数据库是长期存储在计算机内、有组织、可共享的大量数据的集合。**数据库中的数据按一定的数据模型组织、描述和存储,具有**较小的冗余度**、**较高的数据独立性**和**易扩展性**,并可为各种用户共享。
9 | 3. 数据库管理系统:**数据库管理系统是位于用户和操作系统之间的一层数据管理软件。**其主要功能有:**数据定义**、**数据操纵**、**数据库的运行管理**、**数据库的建立以及维护**等4个方面。
10 | 4. 数据库系统:**数据库系统是由数据库、数据库管理系统(及其应用开发工具)、应用程序和数据库管理员组成的存储、管理、处理和维护数据的系统。**
11 |
12 |
13 | ### 数据管理技术的产生和发展
14 |
15 | 1. **人工管理阶段**
16 | 2. **文件系统阶段**
17 | 3. **数据库系统阶段**
18 |
19 | 
20 |
21 | ### 与人工管理相比,数据库系统的特点;
22 |
23 | 1. **数据结构化**
24 | 2. **数据共享度高,冗余度低且易扩充**
25 | 3. **数据独立性高:**数据独立性包括**物理独立性**和**逻辑独立性**。物理独立性是指**用户的应用程序与数据库中数据的物理存储是相互独立的**。逻辑独立性是指**用户的应用程序与数据库的逻辑结构是相互独立的**。
26 | 4. **数据由数据库管理系统统一管理控制:**数据管理系统提供以下数据控制功能:**数据的安全性保护**、**数据的完整性检查**、**并发控制**和**数据库恢复**。
27 |
28 |
29 |
30 | ## 数据模型
31 |
32 | 数据模型也是一种模型,他是对现实世界数据特征的抽象,是数据库系统的核心和基础。
33 |
34 | #### 两类数据模型:
35 |
36 | 1. 第一类是**概念模型**
37 | 2. 第二类是**逻辑模型和物理模型:**逻辑模型主要包括**层次模型、网状模型、关系模型、面向对象数据模型、对象关系数据模型、半结构化数据模型。**物理模型是对数据最底层的抽象。
38 |
39 | 
40 |
41 | ### 概念模型
42 |
43 | #### 信息世界中的基本概念:
44 |
45 | 1. **实体:**客观存在并可相互区别的事物称为实体。
46 | 2. **属性:**实体具有的某一特征称为属性。
47 | 3. **码:**唯一标识尸体的属性集称为码。
48 | 4. **实体型:**用实体名及其属性名集合来抽象和刻画同类实体,称为实体型。
49 | 5. **域:**属性的取值范围。
50 | 6. **实体集:**同一类型实体的集合。
51 |
52 | #### 概念模型的表示方法:
53 |
54 | 表示方法很多,最常用的是**实体—联系**方法。该方法用**E-R**图来描述现实世界的概念模型。
55 |
56 | ### 数据模型:
57 |
58 | #### 三大组成要素:
59 |
60 | 数据模型通常由**数据结构、数据操作和数据的完整性约束条件**三部分组成。
61 |
62 | 1. 数据结构:描述数据库的组成对象以及对象之间的联系。
63 | 2. 数据操作:查询、更新。
64 | 3. 数据的完整性约束条件:一组完整性规则。
65 |
66 | #### 常用的数据模型:
67 |
68 | 1. 层次模型
69 | 2. 网状模型
70 | 3. 关系模型
71 |
72 | ### 关系模型:
73 |
74 | #### 关系模型的数据结构:
75 |
76 | 1. **关系:**一个关系对应常说的一张表。
77 | 2. **元组:**表中的一行。
78 | 3. **元数:**即属性
79 | 4. **属性:**表中的一列。
80 | 5. **码:**表中的某个属性组,它可以唯一确定一个元组。
81 | 6. **关系模式:**对关系的描述,一般表示为:**关系名(属性1,属性2,...,属性n)。**
82 |
83 | #### 关系的完整性约束条件:
84 |
85 | 关系的完整性约束条件分为三大类:**实体完整性,参照完整性和用户定义完整性。**
86 |
87 |
88 |
89 | ## 数据库系统的结构:
90 |
91 | ### 数据库系统模式的概念:
92 |
93 | 在数据库系统中有**型**和**值**的概念,如:(学号,姓名,性别,系别,年龄)这样的纪录是型,而(1607094128,解奕鹏,男,大数据学院,20)则是该记录型的一个记录值。
94 |
95 | **模式**是数据库中全体数据的逻辑结构和特征的描述,他仅仅设计型的描述。模式的一个具体的值称为模式的一个实例,同一个模式可以有很多的实例。
96 |
97 | ### 数据库系统的三级模式结构:
98 |
99 | 三级模式结构由**外模式,模式,内模式**三级构成。
100 |
101 | 
102 |
103 | #### 模式:
104 |
105 | 模式也称逻辑模式,是数据库中**全体数据的逻辑结构和特征的描述**,是所有用户的公共视图。**一个数据库只有一个模式。**
106 |
107 | #### 外模式(子模式):
108 |
109 | 外模式也称**子模式或用户模式**,他是数据库用户能够看见和使用的**局部数据的逻辑挤乳沟和特征的描述**,是数据库用户的数据视图,是与某一应用有关的数据逻辑表示。**一个应用程序只能使用一个外模式。**
110 |
111 | #### 内模式:
112 |
113 | 内模式也称存储模式,一个数据库只有一个内模式。他是**数据物理结构和存储方式的描述**,是数据在数据库内部的组织方式。
114 |
115 | ### 数据库的二级映像功能和数据独立性:
116 |
117 | #### 外模式/模式映像:
118 |
119 | 当模式改变时**(如增加新的关系,新的属性,改变属性的数据类型等)**,由数据库管理人员对各个外模式/模式映像做相应改变,可以使外模式保持不变。应用程序是依据数据的外模式编写的,从而应用程序不必修改,保证了数据与程序的逻辑独立性,简称**数据的逻辑独立性。**
120 |
121 | #### 模式/内模式映像:
122 |
123 | 当数据库的存储结构改变时(**例如选用另一种存储结构**),由数据库管理人员对模式/内模式映像做相应改变,可以使模式保持不变,从而应用程序不必改变。保证了数据与程序之间的物理独立性,简称数据的物理独立性。
124 |
125 |
126 |
127 |
--------------------------------------------------------------------------------
/课本/第七章-数据库设计.md:
--------------------------------------------------------------------------------
1 | # 数据库设计
2 |
3 | ## 数据库设计概述
4 |
5 | ### 数据库设计的基本步骤
6 |
7 | * 需求分析
8 | * 概念结构设计
9 | * 逻辑结构设计
10 | * 物理结构设计
11 | * 数据库实施
12 | * 数据库运行和维护
13 |
14 |
15 |
16 | ## 需求分析
17 |
18 | ### 需求分析的任务
19 |
20 | > 通过详细调查现实世界要处理的对象,充分了解原系统的工作概况,明确用户需求,在此基础上确定新系统的功能
21 |
22 | ### 数据字典
23 |
24 |
25 |
26 | ## 概念结构设计
27 |
28 | > 将需求分析得到的用户需求抽象为**信息结构**的过程就是概念结构设计
29 |
30 | ### E-R模型
31 |
32 |
33 |
34 | ### 概念结构设计
35 |
36 | > 在设计E-R图的过程中如何确定实体与属性,以及在继承E-R图时如何解决冲突等关键技术
37 |
38 | #### E-R图的集成
39 |
40 | * 合并
41 | * 修改和重构
42 |
43 | #### 冲突
44 |
45 | * 属性冲突
46 | * 命名冲突
47 | * 结构冲突
48 |
49 |
50 |
51 | ## 逻辑结构设计
52 |
53 | > 逻辑结构设计的任务是吧概念结构设计阶段设计好的E-R图转换为与选用数据库管理系统产品所支持的数据模型相符合的逻辑结构
54 | >
55 | > `关系模式的数量=实体数量+m:n联系的数量`
56 |
57 |
58 |
59 | ## 物理结构设计
60 |
61 | >为一个给定的逻辑数据模型选取一个最合适应用要求的物理结构的过程,就是物理结构设计。物理结构设计的主要内容就是**为关系模式选择存取方法,以及设计关系,索引等数据文件的物理存储结构。**
62 |
63 |
64 |
65 | ## 数据库的实施
66 |
67 |
68 |
69 | ## 数据库的运行和维护
70 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/课本/第三章关系数据库标准语言SQL.md:
--------------------------------------------------------------------------------
1 | # 第三章关系数据库标准语言SQL
2 |
3 | ## SQL概述
4 |
5 | ### SQL的特点
6 |
7 | 1. 综合统一。
8 | 2. 高度非过程化。
9 | 3. 面向集合的操作方式。
10 | 4. 以同一种语法结构提供多种使用方式。
11 | 5. 语言简洁易学易用。
12 |
13 |
14 |
15 | ### 学生-课程数据库
16 |
17 | 后面的操作都是基于这几个表:
18 |
19 | 
20 |
21 | 
22 |
23 |
24 |
25 | ### 数据定义
26 |
27 | #### 模式的定义与删除:
28 |
29 | 加黑的是可以换掉的。。。
30 |
31 | **<>**表示从中选一个
32 |
33 | 1. 定义模式:
34 |
35 | create schema "**模式名**" authorization **用户名**;
36 |
37 | 2. 删除模式:
38 |
39 | drop schema **模式名** ;
40 |
41 | #### 基本表的定义修改删除
42 |
43 | 1. 定义基本表:
44 |
45 | create table <表名>(...)
46 |
47 | 例:
48 |
49 | ```java
50 | create table Student(
51 | Sno char(9) primery key,//列级完整性条件,Sno是主码
52 | Sname char(20) unique,//Sname取唯一值
53 | Ssex char(2) not null,//列级完整性条件,Ssex不能取空值
54 | Sage smallint,
55 | Sdept char(20)
56 | foreign key (Sname) references Course (C_Sname)//表级完整性约束条件,Sname是外码,被参照表是Course,被参照列是C_Sname
57 | );
58 | ```
59 |
60 | 2. 数据类型:
61 |
62 | 
63 |
64 | 3. 模式与表:
65 |
66 | 每一个基本表都属于一个模式,一个模式包含多个基本表。定义基本表时一般有三种方法定义他的模式:
67 |
68 | * ```java
69 | create table "S-T".Student(···);//Student所属的模式是S-T
70 | ```
71 |
72 | * 在创建模式与剧中同时创建表
73 |
74 | * 设置所属的表
75 |
76 | 4. 修改基本表:
77 |
78 | ```java
79 | alter table <表名>
80 | [add [column] <新列名> <数据类型> [完整性约束条件]]//add 语句用于增加新的列或完整性条件
81 | [add [表级完整性约束条件]]
82 | [drop [column] <列名> [cascade|restrict]]//删除列,指定cascade会删除引用了该列的其他对象,如视图;restrict,rdbms将拒绝删除该列。
83 | [drop constraint <完整性约束名>[restrict|cascade]]//删除约束
84 | [alter column <列名> <数据类型>]
85 | ```
86 |
87 | 5. 删除基本表:
88 |
89 | ```java
90 | drop table <表名>[restrict|cascade];
91 | ```
92 |
93 | #### 索引的建立与删除
94 |
95 | 1. 建立索引:
96 |
97 | ```java
98 | create [unique][cluster] index <索引名>//unique表名此索引的每一个索引值只对应唯一的数据记录,cluster表示建立的索引是聚簇索引
99 | on <表名>(<列名>[<次序>]···);//asc(升序),desc(降序)。
100 | ```
101 |
102 | 2. 修改索引:
103 |
104 | ```java
105 | alter index <旧索引名> rename to <新名>;
106 | ```
107 |
108 | 3. 删除索引:
109 |
110 | ```java
111 | drop index <索引名>
112 | ```
113 |
114 | #### 数据字典
115 |
116 |
117 |
118 | ### 数据查询
119 |
120 | ```java
121 | select [all|distinct]<目标列表达式>[,<目标列表达式>]···//默认为all
122 | from <表名或视图名>[,<表名或视图名>]|(