-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabaseTestController.java
More file actions
28 lines (24 loc) · 1011 Bytes
/
DatabaseTestController.java
File metadata and controls
28 lines (24 loc) · 1011 Bytes
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
package com.leafvillage.backend.Controller.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/db")
public class DatabaseTestController {
@Autowired
private JdbcTemplate jdbcTemplate;
@GetMapping("/test")
public ResponseEntity<String> testDatabaseConnection() {
try {
jdbcTemplate.queryForObject("SELECT 1", Integer.class);
return ResponseEntity.ok("RDS 연결 성공 (Spring Boot)");
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body("RDS 연결 실패: " + e.getMessage());
}
}
}