목록2024/07/14 (4)
wintertreey 님의 블로그
DB 연동방법 4 1. 클래스내에서 직접 sql문 기술2. 스프링이 지원하는 jdbcdao support 사용3. mybatis 프레임워크사용4. jpa 사용 요즘은 jpa를 가장 많이 사용하고, 가장 권장하는 추세라고 한다. 왜일까? 백엔드에서 데이터를 저장하고 조회하려면 데이터베이스를 활용해야 하는데, 백엔드에서 데이터베이스를 사용하는 프레임워크로 가장 많이 쓰이는 기술이 ‘Mybatis’와 ‘JPA' .Java 기반의 Spring 또는 Springboot에서 데이터베이스를 사용하려면 두 가지 기술 중 하나를 사용해야 하기 때문에 Java 백엔드 개발자는 ‘Mybatis’와 ‘JPA’를 반드시 알아야 합니다. 데이터베이스 접속을 편하게 사용하기 위해 SQL Mapper 기술과, ORM(Object ..
DB 연동방법 4가지1. 클래스내에서 직접 sql문 기술2. 스프링이 지원하는 jdbcdao support 사용3. mybatis 프레임워크사용4. jpa 사용 MyBatis란? MyBatis 프레임워크는 반복적인 JDBC 프로그래밍을 단순화하여, 불필요한 Boilerplate 코드를 제거하고, Java 소스코드에서 SQL 문을 분리하여 별도의 XML 파일로 저장하고, 이 둘을 서로 연결시켜주는 기능을 제공해준다. MyBatis의 특징Java 코드와 SQL 매핑MyBatis를 사용하면, MyBatis 내부에서 그러한 Boilerplate 코드가 구현되어 있고, MyBatis에서 Java 메소드와 SQL 간에 매핑을 시켜서 개발자는 Java 메소드 선언과 SQL 문만 만들면 MyBatis가 자동으로 그..
db연동방법41. 클래스내에서 직접 sql문 기술2. 스프링이 지원하는 jdbcdao support 사용3. mybatis 프레임워크사용4. jpa 사용앞에서 살펴본 DataBase 연동방법1은 Spring을 공부하기 전에도 시도했던 방법과 유사했다. 이번에는 Spring에서 제공하는 클래스를 사용하여 db연동을 해보고자한다. jdbcdaosupport란? JdbcDaoSupport 클래스는 Spring 프레임워크에서 제공하는 추상 클래스.데이터베이스와 상호 작용하는 DAO를 개발할 때 편리한 기능을 제공해준다.이 클래스는 JdbcTemplate을 사용하여 데이터베이스 작업을 처리하고, 템플릿 메소드 패턴을 활용하여 일반적인 데이터 액세스 작업을 구현해준다. JdbcDaoSupport 의 멤버메소드..
Spring에서 잘 쓰이는 db 연동방법은 하단처럼 4개. 차례로 하나씩 살펴보려 한다. db 연동방법41. 클래스내에서 직접 sql문 기술2. 스프링이 지원하는 jdbcdao support 사용3. mybatis 프레임워크사용4. jpa 사용 다이어그램 DB연동을 위해 pom.xml에 추가적으로 db관련 dependency들을 기입해줌. SangpumImpl.java에서 디비연동을 위해 클래스에서 디비연동을 해준다. 어노테이션부분을 보면 repository. db연동목적의 클래스임을 확인할 수 있다. @Repositorypublic class SangpumImpl implements SangpumInter { private Connection conn; private PreparedStatem..