forked from Silverados/We-MathAnswerPage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDb.java
More file actions
33 lines (25 loc) · 721 Bytes
/
Db.java
File metadata and controls
33 lines (25 loc) · 721 Bytes
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
package db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Db {
static final String url = "jdbc:mysql://111.230.50.64:3306/wx?useSSL=false";
static final String user = "root";
static final String password = "123456";
private static Connection conn = null;
static {
try {
//1.加载驱动程序
Class.forName("com.mysql.jdbc.Driver");
//2.获得数据库的连接
conn=DriverManager.getConnection(url, user, password);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
public static Connection getConnection(){
return conn;
}
}