Skip to content

Commit 47c5dad

Browse files
authored
[BAEL-5548] MySql Load Driver Error Spring Boot (#18495)
* Initial commit for BAEL-8803 * Remove service test * Initial commit * Review 1 updates * Update to Live test * Review comments * Review comments * AssertJ * [BAEL-5548] Initial commit
1 parent e902e57 commit 47c5dad

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

persistence-modules/spring-boot-mysql/src/main/resources/application.yml

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ spring:
2222
url: jdbc:mysql://localhost:3306/test?
2323
username: root
2424
password:
25+
driver-class-name: com.mysql.cj.jdbc.Driver
2526

2627
---
2728

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.baeldung.boot.mysql;
2+
3+
import static org.junit.jupiter.api.Assertions.assertNotNull;
4+
5+
import java.sql.Connection;
6+
7+
import javax.sql.DataSource;
8+
9+
import org.junit.jupiter.api.Test;
10+
import org.springframework.beans.factory.annotation.Autowired;
11+
import org.springframework.boot.test.context.SpringBootTest;
12+
import org.springframework.test.context.ActiveProfiles;
13+
14+
//Please note, this test requires a MySQL server running on localhost:3306 with database "test" already created.
15+
@SpringBootTest
16+
@ActiveProfiles("dev1")
17+
class LoadDriverLiveTest {
18+
19+
@Autowired
20+
private DataSource dataSource;
21+
22+
@Test
23+
void whenConnectingToDatabase_thenConnectionShouldBeValid() throws Exception {
24+
try (Connection connection = dataSource.getConnection()) {
25+
assertNotNull(connection);
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)