Skip to content

Commit 439f7ce

Browse files
committedMay 4, 2022
Connecting To Other Databases - PostgreSQL
1 parent 10caadd commit 439f7ce

29 files changed

+1131
-2180
lines changed
 

‎26A_ConnectingToOtherDatabases_PostgreSQL/rest-with-spring-boot-and-kotlin-erudio/pom.xml

+7-12
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,13 @@
5959
</dependency>
6060

6161
<dependency>
62-
<groupId>mysql</groupId>
63-
<artifactId>mysql-connector-java</artifactId>
62+
<groupId>org.postgresql</groupId>
63+
<artifactId>postgresql</artifactId>
6464
</dependency>
6565
<dependency>
6666
<groupId>org.flywaydb</groupId>
6767
<artifactId>flyway-core</artifactId>
6868
</dependency>
69-
<dependency>
70-
<groupId>org.flywaydb</groupId>
71-
<artifactId>flyway-mysql</artifactId>
72-
</dependency>
7369

7470
<dependency>
7571
<groupId>com.github.dozermapper</groupId>
@@ -107,7 +103,7 @@
107103

108104
<dependency>
109105
<groupId>org.testcontainers</groupId>
110-
<artifactId>mysql</artifactId>
106+
<artifactId>postgresql</artifactId>
111107
<version>${testcontainers.version}</version>
112108
</dependency>
113109
<dependency>
@@ -149,15 +145,14 @@
149145
<groupId>org.flywaydb</groupId>
150146
<artifactId>flyway-maven-plugin</artifactId>
151147
<configuration>
152-
<url>jdbc:mysql://localhost:3306/rest_with_spring_boot_erudio?useTimezone=true&amp;serverTimezone=UTC&amp;useSSL=false</url>
153-
<user>root</user>
148+
<url>jdbc:postgresql://localhost:5432/rest_with_spring_boot_erudio</url>
149+
<user>postgres</user>
154150
<password>admin123</password>
155151
</configuration>
156152
<dependencies>
157153
<dependency>
158-
<groupId>mysql</groupId>
159-
<artifactId>mysql-connector-java</artifactId>
160-
<version>${mysql.version}</version>
154+
<groupId>org.postgresql</groupId>
155+
<artifactId>postgresql</artifactId>
161156
<exclusions>
162157
<exclusion>
163158
<artifactId>slf4j-api</artifactId>

‎26A_ConnectingToOtherDatabases_PostgreSQL/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/application.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@ security:
99
expire-length: 3600000
1010
spring:
1111
datasource:
12-
driver-class-name: com.mysql.cj.jdbc.Driver
13-
url: jdbc:mysql://localhost:3306/rest_with_spring_boot_erudio?useTimezone=true&serverTimezone=UTC
14-
username: root
12+
driver-class-name: org.postgresql.Driver
13+
url: jdbc:postgresql://localhost:5432/rest_with_spring_boot_erudio
14+
username: postgres
1515
password: admin123
1616
jpa:
1717
hibernate:
1818
ddl-auto: none
1919
properties:
2020
hibernate:
21-
dialect: org.hibernate.dialect.MySQL8Dialect
21+
dialect: org.hibernate.dialect.PostgreSQL92Dialect
22+
jdbc:
23+
lob:
24+
non_contextual_creation: true
2225
show-sql: false
2326
servlet:
2427
multipart:

‎26A_ConnectingToOtherDatabases_PostgreSQL/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V10__Insert_Data_In_User_Permission.sql

-4
This file was deleted.

‎26A_ConnectingToOtherDatabases_PostgreSQL/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V11__Alter_Table_Person.sql

-2
This file was deleted.

‎26A_ConnectingToOtherDatabases_PostgreSQL/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V12__Populate_Person_With_Many.sql

-1,001
This file was deleted.

‎26A_ConnectingToOtherDatabases_PostgreSQL/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V1__Create_Table_Person.sql

-8
This file was deleted.

‎26A_ConnectingToOtherDatabases_PostgreSQL/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V1__Full_Dump_Postgres.sql

+1,106
Large diffs are not rendered by default.

‎26A_ConnectingToOtherDatabases_PostgreSQL/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V2__Populate_Table_Person.sql

-8
This file was deleted.

‎26A_ConnectingToOtherDatabases_PostgreSQL/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V3__Create_Table_Books.sql

-7
This file was deleted.

‎26A_ConnectingToOtherDatabases_PostgreSQL/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V4__Insert_Data_In_Books.sql

-16
This file was deleted.

‎26A_ConnectingToOtherDatabases_PostgreSQL/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V5__Create_Table_Permission.sql

-5
This file was deleted.

‎26A_ConnectingToOtherDatabases_PostgreSQL/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V6__Insert_Data_In_Permission.sql

-4
This file was deleted.

‎26A_ConnectingToOtherDatabases_PostgreSQL/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V7__Create_Table_Users.sql

-12
This file was deleted.

‎26A_ConnectingToOtherDatabases_PostgreSQL/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V8__Insert_Data_In_Users.sql

-3
This file was deleted.

‎26A_ConnectingToOtherDatabases_PostgreSQL/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V9__Create_Table_User_Permission.sql

-8
This file was deleted.

‎26A_ConnectingToOtherDatabases_PostgreSQL/rest-with-spring-boot-and-kotlin-erudio/src/test/kotlin/br/com/erudio/integrationtests/testcontainers/AbstractIntegrationTest.kt

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import org.springframework.context.ApplicationContextInitializer
44
import org.springframework.context.ConfigurableApplicationContext
55
import org.springframework.core.env.MapPropertySource
66
import org.springframework.test.context.ContextConfiguration
7-
import org.testcontainers.containers.MySQLContainer
7+
import org.testcontainers.containers.PostgreSQLContainer
88
import org.testcontainers.lifecycle.Startables
99
import java.util.stream.Stream
1010

@@ -25,17 +25,17 @@ open class AbstractIntegrationTest {
2525

2626
companion object {
2727

28-
private var mysql: MySQLContainer<*> = MySQLContainer("mysql:8.0.28")
28+
private var postgres: PostgreSQLContainer<*> = PostgreSQLContainer("postgres:14.2")
2929

3030
private fun startContainers() {
31-
Startables.deepStart(Stream.of(mysql)).join()
31+
Startables.deepStart(Stream.of(postgres)).join()
3232
}
3333

3434
private fun createConnectionConfiguration(): MutableMap<String, Any> {
3535
return java.util.Map.of(
36-
"spring.datasource.url", mysql.jdbcUrl,
37-
"spring.datasource.username", mysql.username,
38-
"spring.datasource.password", mysql.password,
36+
"spring.datasource.url", postgres.jdbcUrl,
37+
"spring.datasource.username", postgres.username,
38+
"spring.datasource.password", postgres.password,
3939
)
4040
}
4141
}

‎26A_ConnectingToOtherDatabases_PostgreSQL/rest-with-spring-boot-and-kotlin-erudio/src/test/resources/application.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ security:
1111
expire-length: 3600000
1212
spring:
1313
datasource:
14-
driver-class-name: com.mysql.cj.jdbc.Driver
14+
driver-class-name: org.postgresql.Driver
1515
jpa:
1616
hibernate:
1717
ddl-auto: none
1818
properties:
1919
hibernate:
20-
dialect: org.hibernate.dialect.MySQL8Dialect
20+
dialect: org.hibernate.dialect.PostgreSQL92Dialect
21+
jdbc:
22+
lob:
23+
non_contextual_creation: true
2124
show-sql: false
2225
servlet:
2326
multipart:

‎26B_ConnectingToOtherDatabases_SQL_Server/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V10__Insert_Data_In_User_Permission.sql

-4
This file was deleted.

‎26B_ConnectingToOtherDatabases_SQL_Server/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V11__Alter_Table_Person.sql

-2
This file was deleted.

‎26B_ConnectingToOtherDatabases_SQL_Server/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V12__Populate_Person_With_Many.sql

-1,001
This file was deleted.

‎26B_ConnectingToOtherDatabases_SQL_Server/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V1__Create_Table_Person.sql

-8
This file was deleted.

‎26B_ConnectingToOtherDatabases_SQL_Server/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V2__Populate_Table_Person.sql

-8
This file was deleted.

‎26B_ConnectingToOtherDatabases_SQL_Server/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V3__Create_Table_Books.sql

-7
This file was deleted.

‎26B_ConnectingToOtherDatabases_SQL_Server/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V4__Insert_Data_In_Books.sql

-16
This file was deleted.

‎26B_ConnectingToOtherDatabases_SQL_Server/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V5__Create_Table_Permission.sql

-5
This file was deleted.

‎26B_ConnectingToOtherDatabases_SQL_Server/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V6__Insert_Data_In_Permission.sql

-4
This file was deleted.

‎26B_ConnectingToOtherDatabases_SQL_Server/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V7__Create_Table_Users.sql

-12
This file was deleted.

‎26B_ConnectingToOtherDatabases_SQL_Server/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V8__Insert_Data_In_Users.sql

-3
This file was deleted.

‎26B_ConnectingToOtherDatabases_SQL_Server/rest-with-spring-boot-and-kotlin-erudio/src/main/resources/db/migration/V9__Create_Table_User_Permission.sql

-8
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.