forked from MebukiYamashita/Sideproject_LMS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbConnection.java
More file actions
24 lines (20 loc) · 729 Bytes
/
dbConnection.java
File metadata and controls
24 lines (20 loc) · 729 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
import java.sql.*;
public class dbConnection {
private static final String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver";
private static final String DB_URL = "jdbc:mysql://localhost:3306/metadb";
private static final String USER = "root";
private static final String PASS = "root1234";
private static Connection conn = null;
public static Connection getInstance() {
if(conn == null){
try {
Class.forName(JDBC_DRIVER);
conn = DriverManager.getConnection(DB_URL, USER, PASS);
System.out.println("DB 연결됨");
} catch(Exception e) {
e.printStackTrace();
}
}
return conn;
}
}