Return to site

🍃🎓 SPRING CERTIFICATION QUESTION: How do you configure a DataSource in Spring? Which bean is beneficial for development/test databases?

· java,spring,vcp

Answer:

DataSource is a factory to obtain database connections. There're several ways to create DataSource beans in a Spring application:

- using JNDI lookup

- using JDBC DataSource vendors

- using test-purpose DataSource implementations provided by Spring Framework (e.g. DriverManagerDataSource, SingleConnectionDataSource, embedded Datasource created via EmbeddedDatabaseBuilder class).

Preferable development DataSource is a pooled-Datasource obtained by JNDI lookup. For testing purposes, embedded Datasource EmbeddedDatabase is sometimes sufficient.

Examples of mentioned terms:

SampleDataSourceConfiguration - basic example for configuring production/development Datasource s.(in the attachment below)👇👇👇

broken image

#spring #certificationquestion #vcp