Vert.x와 Spring Boot는 DB 연결 방식과 프로그래밍 패러다임이 매우 다릅니다. Vert.x는 비동기 논블로킹 방식, Spring Boot는 동기적/블로킹 방식(JPA 등) 위주로 구성합니다.
Vert.x 데이터베이스 연결 요약
-
비동기, 논블로킹 API(Utilizes Async SQL 클라이언트)
-
Vert.x 자체 Pool 관리
-
JDBC, PostgreSQL, MySQL 등 각각 별도 클라이언트 라이브러리 사용(대표적으로 vertx-jdbc-client, vertx-mysql-client)
-
Callback 또는 Future/Promise 패턴으로 결과 처리
-
트랜잭션도 비동기 체인 방식으로 연결
Vert.x DB 연결 샘플 (PostgreSQL, Java)
PgConnectOptions connectOptions = new PgConnectOptions()
.setPort(5432)
.setHost("localhost")
.setDatabase("testdb")
.setUser("user")
.setPassword("password");PoolOptions poolOptions = new PoolOptions().setMaxSize(5);PgPool client = PgPool.pool(vertx, connectOptions, poolOptions);
client.getConnection(ar -> {
if (ar.succeeded()) {
SqlConnection connection = ar.result();
connection.query(“SELECT * FROM users”).execute(res -> {
if (res.succeeded()) {
RowSet<Row> rows = res.result();
for (Row row : rows) {
System.out.println(row.getString(“name”));
}
}
connection.close();
});
}
});
-
콜백 기반으로 결과를 받음, 연결 및 쿼리, close 자체도 논블로킹.
Spring Boot 데이터베이스 연결 요약
-
동기, Repository 및 JPA(ORM) 기반으로 주로 사용
-
Spring의 DataSource 및 커넥션 풀 자동 관리
-
@Repository, @Service, @Autowired 등 의존성 주입 방식으로 레퍼런스 연결
-
트랜잭션 관리도 @Transactional 같은 어노테이션 활용해 자동화
Spring Boot DB 연결 샘플 (JPA, Java)
@Entity
public class User {
@Id
private Long id;
private String name;
// getter/setter
}public interface UserRepository extends JpaRepository<User, Long> {}
@Service
public class UserService {
@Autowired
private UserRepository userRepository;
public List<User> getAllUsers() {
return userRepository.findAll();
}
}
@RestController
public class UserController {
@Autowired
private UserService userService;
@GetMapping(“/users”)
public List<User> users() {
return userService.getAllUsers();
}
}
-
대부분 동기적으로 처리, Spring Boot가 커넥션 풀과 트랜잭션을 자동 관리.
Vert.x vs Spring Boot DB 연결 방식 비교

| 구분 | Vert.x | Spring Boot |
|---|---|---|
| 프로그래밍 모델 | 비동기/이벤트 기반(Callback, Future) | 동기(Block), 리액티브(WebFlux로 가능) |
| 커넥션 풀 | Vert.x Pool 직접 생성/관리 | Spring이 자동설정(주로 HikariCP) |
| 쿼리 실행 방식 | 논블로킹, 핸들러(Handler)에서 처리 | 동기식(JPA, MyBatis 등 클래스·인터페이스로 추상화) |
| 트랜잭션 관리 | 수동, 비동기 체인(CompositeFuture) | 어노테이션으로 선언(@Transactional 등) |
| 코드 복잡도 | 콜백 지옥 위험, Promise·Future 이용으로 개선 가능 | 구조적, 선언적, Enterprise 패턴 지원 |
| 대표 의존성 | vertx-jdbc-client, vertx-pg-client, vertx-mysql-client 등 | spring-boot-starter-data-jpa, spring-boot-starter-jdbc |
-
Vert.x는 고성능, 대규모 실시간, 비동기 시스템에 강점.
-
Spring Boot는 구조적이고 생산성이 높아 엔터프라이즈 환경에 유리.
각 상황에 맞춘 선택이 필요하며, Vert.x는 수동 제어, Spring Boot는 편의성과 자동화 위주입니다.