231226 JAVA DBConnection

2023. 12. 26. 19:362023.11.21-2024.05.31

package com.sukgi.db;

 

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.SQLException;

 

//접속 정보만 가지고 있는 클래스

public class DBConnection {

public Connection getConnection() {

// 갯턴을 실행시키면 접속시키는 (커넥션)이 나온다.

Connection con = null;

// 욕심은....싱글턴 패턴화 시키는거...?

try {

Class.forName("org.mariadb.jdbc.Driver");

String url = "jdbc:mariadb://guro.wisejia.com:3308/employees";

String user = "c23c_22";

String pw = "01234567";

con = DriverManager.getConnection(url, user, pw);

} catch (ClassNotFoundException e) {

System.out.println("클래스가 없습니다.");

} catch (SQLException e) {

// e.printStackTrace();

System.out.println("접속 정보를 확인하세요.");

 

}

 

return con;

}

}

 

 

d009: Customer Service

d005: Development

d002: Finance

d003: Human Resources

d001: Marketing

d004: Production

d006: Quality Management

d008: Research

d007: Sales

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

231226 JAVA Test  (0) 2023.12.27
231226 JAVA EmployeesDAO  (1) 2023.12.26
231226 JAVA DB01  (0) 2023.12.26
231226 JAVA Exception03  (0) 2023.12.26
231226 JAVA Exception02  (0) 2023.12.26