Skip to content

Commit ea5195c

Browse files
committed
Better document how DataSource is bound to the env
Closes gh-4971
1 parent 2dc3660 commit ea5195c

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,19 +2315,37 @@ DataSource configuration is controlled by external configuration properties in
23152315
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
23162316
----
23172317

2318-
See {sc-spring-boot-autoconfigure}/jdbc/DataSourceProperties.{sc-ext}[`DataSourceProperties`]
2319-
for more of the supported options. Note also that you can configure any of the
2320-
`DataSource` implementation specific properties via `+spring.datasource.*+`: refer to the
2321-
documentation of the connection pool implementation you are using for more details.
2322-
23232318
TIP: You often won't need to specify the `driver-class-name` since Spring boot can deduce
23242319
it for most databases from the `url`.
23252320

23262321
NOTE: For a pooling `DataSource` to be created we need to be able to verify that a valid
23272322
`Driver` class is available, so we check for that before doing anything. I.e. if you set
2328-
`spring.datasource.driverClassName=com.mysql.jdbc.Driver` then that class has to be
2323+
`spring.datasource.driver-class-name=com.mysql.jdbc.Driver` then that class has to be
23292324
loadable.
23302325

2326+
See {sc-spring-boot-autoconfigure}/jdbc/DataSourceProperties.{sc-ext}[`DataSourceProperties`]
2327+
for more of the supported options. These are the standard options that work regardless of
2328+
the actual implementation. It is also possible to fine tune implementation-specific settings
2329+
using the `+spring.datasource.*+` prefix, refer to the documentation of the connection pool
2330+
implementation you are using for more details.
2331+
2332+
For instance, if you are using the
2333+
http://tomcat.apache.org/tomcat-8.0-doc/jdbc-pool.html#Common_Attributes[Tomcat connection pool]
2334+
you could customize many additional settings:
2335+
2336+
2337+
[source,properties,indent=0]
2338+
----
2339+
# Number of ms to wait before throwing an exception if no connection is available.
2340+
spring.datasource.max-wait=10000
2341+
2342+
# Maximum number of active connections that can be allocated from this pool at the same time.
2343+
spring.datasource.max-active=50
2344+
2345+
# Validate the connection before borrowing it from the pool.
2346+
spring.datasource.test-on-borrow=true
2347+
----
2348+
23312349

23322350

23332351
[[boot-features-connecting-to-a-jndi-datasource]]

0 commit comments

Comments
 (0)