1. MySQL 설치
https://dev.mysql.com/downloads/mysql/
MySQL :: Download MySQL Community Server
Select Operating System: Select Operating System… Microsoft Windows Ubuntu Linux Debian Linux SUSE Linux Enterprise Server Red Hat Enterprise Linux / Oracle Linux Fedora Linux - Generic Oracle Solaris macOS Source Code Select OS Version: All Windows (x86
dev.mysql.com


https://dev.mysql.com/downloads/connector/j/
MySQL :: Download Connector/J
MySQL Connector/J 8.0 is highly recommended for use with MySQL Server 8.0, 5.7 and 5.6. Please upgrade to MySQL Connector/J 8.0.
dev.mysql.com

2. 이클립스와 연동
다운받은 connecter의 압축을 풀어준 다음 mysql-connector-java-8.0.28 파일을 복사해서

설치된 Java - [lib]에 [extlib]폴더를 만든 후 붙여넣기한다.

[프로젝트]-[WebContent]-[WEB INF]-[lib]에도 붙여넣기

프로젝트에서 우클릭 Build Path에 들어가서

Livraries에 Web App Libaries를 확인해보면 jar 파일이 있는 것을 확인할 수 있다.

3. java Class 만들어서 연동 테스트 해보기

package study;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DriverTest {
public static void main(String[] args) {
Connection con;
try {
Class.forName("com.mysql.cj.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306","root","비밀번호");
System.out.println("Success");
}catch(SQLException ex) {
System.out.println("SQLExceptin" + ex);
}catch(Exception e) {
System.out.println("Exception"+e);
}
}
}

Success가 뜬 걸 확인할 수 있다.

Data Source Explorer에 가서 Database Connections 선택한 다음 New... 클릭


Name/Type 에서는 5.1, [JAR List]로 들어가서 Edit Jar/Zip...를 클릭한다음

mysql-connector-java-8.0.28을 선택


Test Connection을 클릭하면 성공했다고 뜬다.

MySQL이 추가된걸 확인할 수 있다.

'Back > Database' 카테고리의 다른 글
| [MYSQL] 오류코드 1452 (0) | 2023.10.06 |
|---|---|
| [GraphQl] GraphQl - Codegen 설치하기 (0) | 2023.03.26 |
| [GraphQL] Query 와 Mutation (0) | 2023.03.15 |
| [GraphQL] GraphQL이란? (0) | 2023.03.10 |
