231227 JAVA DBConnection

2023. 12. 27. 19:112023.11.21-2024.05.31

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
package conn.sukgi.db;
 
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
 
//접속 정보만 가지고 있는 클래스
 
public class DBConnection {
    public Connection getConn() {// 메소드 정의
        Connection connection = null;// 변수 선언, 초기화
 
        try {// 드라이버 로드 및 연결 정보 설정
            Class.forName("org.mariadb.jdbc.Driver");// jdbc 드라이버를 로드
 
            String url = "jdbc:mariadb://guro.wisejia.com:3308/employess";
            String user = "c23c_22";
            String pw = "01234567";
 
            connection = DriverManager.getConnection(url, user, pw);
            // 데이터베이스 연결
 
            // 예외 처리
        } catch (ClassNotFoundException e) {
 
            e.printStackTrace();
        } catch (SQLException e) {
 
            e.printStackTrace();
        }
 
        return connection;// 연결 반환
    }
 
}
 
cs

'2023.11.21-2024.05.31' 카테고리의 다른 글

231227 JAVA EmployeesDAO  (0) 2023.12.27
231227 JAVA EmployeesDTO  (1) 2023.12.27
231226 JAVA EmployeesDTO  (0) 2023.12.27
231226 JAVA Test  (0) 2023.12.27
231226 JAVA EmployeesDAO  (1) 2023.12.26