🍃🎓 SPRING CERTIFICATION QUESTION: How do you configure a DataSource in Spring? Which bean is beneficial for development/test databases?
🍃🎓 SPRING CERTIFICATION QUESTION: How do you configure a DataSource in Spring? Which bean is beneficial for development/test databases?
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](http://custom-images.strikinglycdn.com/res/hrscywv4p/image/upload/c_limit,fl_lossy,h_9000,w_1200,f_auto,q_auto/784839/734515_5714.png)
#spring #certificationquestion #vcp
Configuring a DataSource👉 https://www.baeldung.com/spring-boot-configure-data-source-programmatic