Skip to content

Commit 29b46a9

Browse files
authored
Fix [#1266] (#1267)
1 parent 32f5f9e commit 29b46a9

File tree

1 file changed

+26
-23
lines changed

1 file changed

+26
-23
lines changed

examples/SpringHibernateExample/README.md

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -142,38 +142,41 @@ Please note that the sample code inside the AWS JDBC Driver project will use the
142142
Configure Spring to use the AWS Advanced JDBC Driver as the default datasource.
143143

144144
1. In the `application.yml`, add a new datasource for Spring:
145-
```yaml
146-
datasource:
147-
url: jdbc:aws-wrapper:postgresql://db-identifier.cluster-XYZ.us-east-2.rds.amazonaws.com:5432/db
148-
username: jane_doe
149-
driver-class-name: software.amazon.jdbc.Driver
150-
hikari:
151-
data-source-properties:
152-
wrapperPlugins: iam,failover,efm2
153-
iamRegion: us-east-2
154-
iamExpiration: 1320
155-
exception-override-class-name: software.amazon.jdbc.util.HikariCPSQLException
156-
max-lifetime: 1260000
157-
```
145+
146+
```yaml
147+
spring:
148+
datasource:
149+
url: jdbc:aws-wrapper:postgresql://db-identifier.cluster-XYZ.us-east-2.rds.amazonaws.com:5432/db
150+
username: jane_doe
151+
driver-class-name: software.amazon.jdbc.Driver
152+
hikari:
153+
data-source-properties:
154+
wrapperPlugins: iam,failover,efm2
155+
iamRegion: us-east-2
156+
iamExpiration: 1320
157+
exception-override-class-name: software.amazon.jdbc.util.HikariCPSQLException
158+
max-lifetime: 1260000
159+
```
158160
Since Spring 2+ uses Hikari to manage datasources, to configure the driver we would need to specify the `data-source-properties` under `hikari`.
159161
Whenever Hikari is used, we also need to ensure failover exceptions are handled correctly so connections will not be discarded from the pool after failover has occurred. This can be done by overriding the exception handling class. For more information on this, please see [the documentation on HikariCP](../../docs/using-the-jdbc-driver/using-plugins/UsingTheFailoverPlugin.md#hikaricp).
160162

161163
This example contains some very simple configurations for the IAM Authentication plugin, if you are interested in other configurations related to failover, please visit [the documentation for failover parameters](../../docs/using-the-jdbc-driver/using-plugins/UsingTheFailoverPlugin.md#failover-parameters)
162164
2. Configure Hibernate dialect:
163-
```yaml
164-
jpa:
165+
166+
```yaml
167+
spring:
168+
jpa:
165169
properties:
166170
hibernate:
167171
dialect: org.hibernate.dialect.PostgreSQLDialect
168-
```
172+
```
169173
3. [Optional] You can enable driver logging by adding the following to `application.yml`:
170-
```yaml
171-
logging:
172-
level:
173-
software:
174-
amazon:
175-
jdbc: TRACE
176-
```
174+
175+
```yaml
176+
logging:
177+
level:
178+
software.amazon.jdbc: TRACE
179+
```
177180

178181
Start the application by running `./gradlew :springhibernate:bootRun` in the terminal. You should see the application making a connection to the database and fetching data from the Example table.
179182

0 commit comments

Comments
 (0)