Bird
0
0

A Spring Boot application fails to start due to a database connection error. The application.properties file has:

medium📝 Debug Q7 of 15
Spring Boot - Docker and Deployment
A Spring Boot application fails to start due to a database connection error. The application.properties file has:
spring.datasource.url=jdbc:mysql://localhost:3306/mydb
spring.datasource.username=root
spring.datasource.password=wrongpass

What is the most likely fix?
ARemove the <code>spring.datasource.url</code> property
BChange the database port to 8080
CAdd <code>@EnableJpaRepositories</code> annotation to main class
DCorrect the database password in <code>application.properties</code>
Step-by-Step Solution
Solution:
  1. Step 1: Identify cause of connection failure

    Incorrect password causes authentication failure to the database.
  2. Step 2: Apply fix by correcting password

    Updating the password to the correct one in application.properties resolves the issue.
  3. Final Answer:

    Correct the database password in application.properties -> Option D
  4. Quick Check:

    DB connection error = wrong password fix [OK]
Quick Trick: Check DB credentials in properties file [OK]
Common Mistakes:
  • Removing datasource URL breaks connection
  • Adding annotations unrelated to connection
  • Changing port to unrelated value

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes