java.sql.SQLSyntaxErrorException: Unknown database 'myDB' java.lang.IllegalStateException: Failed to execute CommandLineRunner at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:772) ~[spring-boot-3.0.5.jar:3.0.5] Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection ... Caused by: java.sql.SQLSyntaxErrorException: Unknown database 'myDB' at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) ... 22 common frames omitted
If you provide a wrong or incorrect Database name in your Spring Boot project application.properties file you are bound to get the Unknown database exception.
- Make sure you have provided the right database name in the application.properties file.
- Connect to the database and check if you have the database present. Make use of the show databases; query to check.
- Make sure that you are connecting to the right Database server, it could be so that you are in the wrong database (eg Staging/UAT instead of Prod)
- Check with the DBA that you have access to the database.
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to Java,
- CRUD operations in Spring Boot + JDBC
- Java Check Leap Year - Programs with Code Examples
- [fix] Java JDBC ConnectException: Connection refused
- How to add hours and minutes to Java Instant
- Java Program: Random Number Generator
- Java: The value of the local variable string is not used
- How to get list of all Java versions installed on macOS
- Java SE JDBC with Prepared Statement Parameterized Select Example
- Java + Spring JDBC Template + Gradle Example
- Convert String to LocalDate in Java
- Remove Trailing zeros BigDecimal Java
- Java 8 Predicate Functional Interface isEqual() Method Example
- How to Hardcode Date in Java with Examples
- Java 8: Predicate negate() default Function Example
- Java: Collect Stream as ArrayList or LinkedList
- The Motivation Behind Generics in Java Programming
- How to Add/Subtract Days to the Current Date in Java
- Error: Can not find the tag library descriptor for
- Setting up JUnit 5 dependency with Maven Example
- Run Java Code Every Second
- How to create a tar.gz file using Java
- [Fix] java: integer number too large compilation error
- Java 8: Find the Max value in a List
- Your JBoss Application Server 7 is running However you have not yet added any users to be able to access the admin console
- Convert Java Array to ArrayList Code Example
- How to install Classic Notepad App on Windows 11 - Windows-11
- How to update Microsoft Excel on Mac - Windows
- How to Install C Plus Plus (C++) on M1/M2 macOS - MacOS
- How to know Roblox Version Details on Mac - MacOS
- How to download Microsoft Visual Studio for M1/M2 Mac - MacOS
- Enable Eclipse dark mode - Eclipse
- Get HTML table td, tr or th inner content value with id or name attribute - Html