Skip to content

Commit ddeff06

Browse files
committed
update
1 parent 3fd9a4a commit ddeff06

File tree

8 files changed

+107
-5
lines changed

8 files changed

+107
-5
lines changed

java/Javaweb2020逃跑计划/1.MySQL/MySQL.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@
3535
- 2.19 [删除多余的用户](#删除多余的用户)
3636
- 2.20 [创建用户并授权](#创建用户并授权)
3737
- 2.21 [为现有的表加字段](#为现有的表加字段)
38-
- 2.2 [一次插入多条记录](#一次插入多条记录)
39-
- 2.2 [](#)
38+
- 2.22 [一次插入多条记录](#一次插入多条记录)
39+
- 2.23 [修改普通用户的密码](#修改普通用户的密码)
40+
41+
4042

4143

4244
3. [MySQL约束](#3-mysql-约束)
@@ -1301,6 +1303,13 @@ insert into t_category (cname) values ('傻逼游'), ('坑钱游'), ('QNMD游'),
13011303
13021304
```
13031305

1306+
### 修改普通用户的密码
1307+
1308+
```
1309+
1310+
set password for 'doukeyi'@'%' =password('123456a');
1311+
1312+
```
13041313

13051314
## 3 mysql 约束
13061315

@@ -2298,13 +2307,15 @@ set @@autocommit = 0;
22982307
22992308
```
23002309

2310+
事务的四大特性ACID
2311+
2312+
![QQ20191217-204249@2x](images/QQ20191217-204249@2x.png)
2313+
23012314
### 自动提交
23022315
### 事务原理
23032316
### 回滚点
23042317
### 事务的隔离级别
2305-
2306-
事务的四大特性ACID
2307-
2318+
![QQ20191217-204609@2x](images/QQ20191217-204609@2x.png)
23082319

23092320

23102321
## 9用户管理和权限
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# 目录
2+
3+
4+
1. [](#)
5+
- 1.1
6+
7+
2. [](#)
8+
9+
- 2.0 [](#)
10+
- 2.0.1 [ ](#)
11+
- 2.0.1.1 [](#)
12+
- 2.0.1.2 [](#)
13+
14+
15+
16+
17+
18+
### 数据库驱动
19+
20+
```
21+
22+
mysql-connector-java
23+
24+
https://dev.mysql.com/downloads/connector/j/5.1.html
25+
26+
```
27+
28+
29+
30+
### 从 JDBC3 开始,目前已经普遍使用的版本。可以不用注册驱动而直接使用。Class.forName 这句话可以省略。
31+
32+
```
33+
34+
Class.forName("com.mysql.jdbc.Driver");
35+
36+
37+
```
38+
39+
40+
### JDBC 基本连接
41+
42+
43+
```
44+
45+
package com.domanshow.jdbc.demo1;
46+
47+
import java.sql.Connection;
48+
import java.sql.DriverManager;
49+
import java.sql.SQLException;
50+
import java.util.Properties;
51+
52+
public class JDBCDemo1Main {
53+
54+
public static void main(String[] args) throws ClassNotFoundException, SQLException {
55+
56+
Class.forName("com.mysql.jdbc.Driver");
57+
58+
System.out.println("hello JDBC");
59+
60+
jdbcCollection2();
61+
62+
}
63+
64+
// 1) 使用用户名、密码、URL得到连接对象
65+
public static void jdbcCollection1() throws SQLException {
66+
67+
String url = "jdbc:mysql://65.42.40.36:3306/myutf8"; //1) 使用用户名、密码、URL 得到连接对象
68+
Connection connection = DriverManager.getConnection(url, "doukeyi", "123456a"); //com.mysql.jdbc.JDBC4Connection@68de145
69+
System.out.println(connection);
70+
}
71+
72+
// 2) 使用属性文件和url得到连接对象
73+
public static void jdbcCollection2() throws SQLException {
74+
75+
String url = "jdbc:mysql://65.42.40.36:3306/myutf8";
76+
// 属性对象
77+
Properties info = new Properties();
78+
info.setProperty("user", "doukeyi");
79+
info.setProperty("password", "123456a");
80+
81+
Connection connection = DriverManager.getConnection(url, info);
82+
83+
System.out.println(connection);
84+
}
85+
}
86+
87+
88+
```
89+
90+
91+
Binary file not shown.

0 commit comments

Comments
 (0)