1

I have a VM running an MsSQL database. I was previously using an Oracle database. My app injects some sample data on startup and I get this error:

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'springbootdb.users'.

data.sql

INSERT INTO "springbootdb"."users" (USER_ID, EMAIL, FIRST_NAME, INITIAL_NAME, LAST_NAME, PASSWORD, ROLE, ENABLED, CURRENT_STATUS, POSITION_TITLE) VALUES ('1', 'asdf@asdf.com', 'asdf', 'asdf', 'asdf', '12345', 0, 1, 'In Office', 'Advanced Developer');
INSERT INTO "springbootdb"."users" (USER_ID, EMAIL, FIRST_NAME, INITIAL_NAME, LAST_NAME, PASSWORD, ROLE, ENABLED, CURRENT_STATUS, POSITION_TITLE) VALUES ('2', 'asdf@asdf.com', 'asdf', 'asdf', 'asdf', '12345', 0, 1, 'In Office', 'Associate Developer');
INSERT INTO "springbootdb"."users" (USER_ID, EMAIL, FIRST_NAME, INITIAL_NAME, LAST_NAME, PASSWORD, ROLE, ENABLED, CURRENT_STATUS, POSITION_TITLE) VALUES ('3', 'asdf@asdf.com', 'asdf', 'asdf', 'adsf', '12345', 1, 1, 'In Office', 'Line Manager');

application.properties

# MsSQL Connection
spring.datasource.url=jdbc:sqlserver://11.11.111.1:1433;database=springbootdb;
spring.datasource.username=admin
spring.datasource.password=123!
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.show-sql=true
spring.jpa.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
spring.jpa.hibernate.ddl-auto=create-drop

I have tested that there is indeed a connection. I can also access the database from MSQLSMS from an sql account, as shown in the picture below:

enter image description here

Why am I getting this error?

2

The table name in your insert should be springbootdb.dbo.users

1
  • Any update on my answer? Apr 29 '17 at 19:19
0

use the schema on your pojo (table entity)

import javax.persistence.Table;
@Table(schema = "dbo", name = "users")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.