Skip to content
Advertisement

How to resolve SQLServerException: Invalid object name?

I am creating a spring boot application using MS SQL server. I have a requirement where I need to initialize USERS table in user_database database using data.sql file placed in /src/main/resources/ folder and rest of the tables should be created automatically in springboot_db database with the help of @Table annotation. Below is the code snippet.

applicaiton.properties file

JavaScript

data.sql

JavaScript

AppConfiguration.java (One of the entity file)

JavaScript

If I am running my application keeping both the approaches separately than its working fine. When I merge both into a single application, it is showing following error.

JavaScript

Advertisement

Answer

Using the same database for both the tables resolves my issue. However, I am still confused as to why I am not allowed to use two different databases?

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement